Skip to content

Commit 02dcd32

Browse files
author
Mariano Custiel
committed
Fix: Avoid array to string conversion for non-string body matchers
1 parent 303add6 commit 02dcd32

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Domain/Request.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,18 @@ class Request implements \JsonSerializable
5454

5555
public function __toString()
5656
{
57+
if (isset($this->body)) {
58+
$bodyValue = $this->body->getValue();
59+
if (!is_string($bodyValue)) {
60+
$bodyValue = print_r($bodyValue, true);
61+
}
62+
}
63+
5764
return print_r(
5865
[
5966
'method' => $this->method,
6067
'url' => isset($this->url) ? $this->url->__toString() : 'null',
61-
'body' => isset($this->body) ? $this->body->getMatcher() . ' => ' . (isset($this->body->getValue()[5000]) ? '--VERY LONG CONTENTS--' : $this->body->getValue()) : 'null',
68+
'body' => isset($this->body) ? $this->body->getMatcher() . ' => ' . (isset($bodyValue[5000]) ? '--VERY LONG CONTENTS--' : $bodyValue) : 'null',
6269
'headers' => print_r($this->headers, true),
6370
],
6471
true

0 commit comments

Comments
 (0)