Skip to content

Commit a2da83d

Browse files
committed
[HttpFoundation] Tweak previous merged PR
1 parent 0bf83f6 commit a2da83d

File tree

5 files changed

+26
-27
lines changed

5 files changed

+26
-27
lines changed

Test/Constraint/ResponseFormatSame.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@ final class ResponseFormatSame extends Constraint
2525
private Request $request;
2626
private ?string $format;
2727

28-
public function __construct(Request $request, ?string $format)
29-
{
28+
public function __construct(
29+
Request $request,
30+
?string $format,
31+
private readonly bool $verbose = true,
32+
) {
3033
$this->request = $request;
3134
$this->format = $format;
3235
}
@@ -57,6 +60,6 @@ protected function failureDescription($response): string
5760
*/
5861
protected function additionalFailureDescription($response): string
5962
{
60-
return (string) $response;
63+
return $this->verbose ? (string) $response : explode("\r\n\r\n", (string) $response)[0];
6164
}
6265
}

Test/Constraint/ResponseIsRedirected.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ protected function failureDescription($response): string
4444
return 'the Response '.$this->toString();
4545
}
4646

47-
protected function additionalFailureDescription($other): string
47+
/**
48+
* @param Response $response
49+
*/
50+
protected function additionalFailureDescription($response): string
4851
{
49-
if ($this->verbose || !($other instanceof Response)) {
50-
return (string) $other;
51-
} else {
52-
return explode("\r\n\r\n", (string) $other)[0];
53-
}
52+
return $this->verbose ? (string) $response : explode("\r\n\r\n", (string) $response)[0];
5453
}
5554
}

Test/Constraint/ResponseIsSuccessful.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ protected function failureDescription($response): string
4444
return 'the Response '.$this->toString();
4545
}
4646

47-
protected function additionalFailureDescription($other): string
47+
/**
48+
* @param Response $response
49+
*/
50+
protected function additionalFailureDescription($response): string
4851
{
49-
if ($this->verbose || !($other instanceof Response)) {
50-
return (string) $other;
51-
} else {
52-
return explode("\r\n\r\n", (string) $other)[0];
53-
}
52+
return $this->verbose ? (string) $response : explode("\r\n\r\n", (string) $response)[0];
5453
}
5554
}

Test/Constraint/ResponseIsUnprocessable.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ protected function failureDescription($other): string
4444
return 'the Response '.$this->toString();
4545
}
4646

47-
protected function additionalFailureDescription($other): string
47+
/**
48+
* @param Response $response
49+
*/
50+
protected function additionalFailureDescription($response): string
4851
{
49-
if ($this->verbose || !($other instanceof Response)) {
50-
return (string) $other;
51-
} else {
52-
return explode("\r\n\r\n", (string) $other)[0];
53-
}
52+
return $this->verbose ? (string) $response : explode("\r\n\r\n", (string) $response)[0];
5453
}
5554
}

Test/Constraint/ResponseStatusCodeSame.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ protected function failureDescription($response): string
4444
return 'the Response '.$this->toString();
4545
}
4646

47-
protected function additionalFailureDescription($other): string
47+
/**
48+
* @param Response $response
49+
*/
50+
protected function additionalFailureDescription($response): string
4851
{
49-
if ($this->verbose || !($other instanceof Response)) {
50-
return (string) $other;
51-
} else {
52-
return explode("\r\n\r\n", (string) $other)[0];
53-
}
52+
return $this->verbose ? (string) $response : explode("\r\n\r\n", (string) $response)[0];
5453
}
5554
}

0 commit comments

Comments
 (0)