@@ -99,7 +99,7 @@ public function isJson(MessageInterface $message): bool
99
99
public function getJson (MessageInterface $ message ): ?array
100
100
{
101
101
return $ this ->replaceParameters (
102
- json_decode ($ message ->getBody (), true ),
102
+ json_decode ($ message ->getBody ()-> __toString () , true ),
103
103
$ this ->jsonFilters ,
104
104
$ this ->values ,
105
105
$ this ->replace
@@ -111,9 +111,9 @@ public function getContent(MessageInterface $message): string
111
111
if ($ this ->isJson ($ message )) {
112
112
$ body = json_encode ($ this ->getJson ($ message ));
113
113
} else {
114
- $ body = $ message ->getBody ()->getContents ();
114
+ $ body = $ message ->getBody ()->__toString ();
115
115
foreach ($ this ->values as $ value ) {
116
- $ body = $ this -> replace ($ value , $ this ->replace , $ body );
116
+ $ body = str_replace ($ value , $ this ->replace , $ body );
117
117
}
118
118
}
119
119
@@ -122,14 +122,7 @@ public function getContent(MessageInterface $message): string
122
122
123
123
public function filter (MessageInterface $ message ): MessageInterface
124
124
{
125
- if ($ this ->isJson ($ message )) {
126
- $ body = json_encode ($ this ->getJson ($ message ));
127
- } else {
128
- $ body = $ message ->getBody ()->getContents ();
129
- foreach ($ this ->values as $ value ) {
130
- $ body = $ this ->replace ($ value , $ this ->replace , $ body );
131
- }
132
- }
125
+ $ body = $ this ->getContent ($ message );
133
126
134
127
foreach ($ this ->getHeaders ($ message ) as $ header => $ values ) {
135
128
$ message = $ message ->withHeader ($ header , $ values );
@@ -146,7 +139,7 @@ protected function replaceParameters(array $array, array $parameters, array $val
146
139
}
147
140
}
148
141
149
- array_walk_recursive ( $ array , function (&$ item, $ key ) use ($ values , $ replace , $ strict ) {
142
+ array_walk_recursive ( $ array , function (&$ item ) use ($ values , $ replace , $ strict ) {
150
143
foreach ($ values as $ value ) {
151
144
if (! $ strict && str_contains ($ item , $ value )) {
152
145
$ item = str_replace ($ value , $ replace , $ item );
0 commit comments