Conditions | 5 |
Paths | 4 |
Total Lines | 26 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
26 | public function format(Request $request, ?Response $response, ?\Throwable $exception, ?string $message = null): string |
||
27 | { |
||
28 | if (!$message) { |
||
29 | return ''; |
||
30 | } |
||
31 | |||
32 | $matchPattern = sprintf('/{{%s_header\.(.*?)}}/', $this->getPrefix()); |
||
33 | $matched = preg_match_all($matchPattern, $message, $matches); |
||
34 | if (!$matched || 2 !== \count($matches)) { |
||
|
|||
35 | return $message; |
||
36 | } |
||
37 | |||
38 | $matchesPattern = $matches[0]; |
||
39 | $matchesVars = $matches[1]; |
||
40 | |||
41 | $countMatches = \count($matchesVars); |
||
42 | |||
43 | for ($i = 0; $i < $countMatches; ++$i) { |
||
44 | $message = str_ireplace( |
||
45 | $matchesPattern[$i], |
||
46 | $this->getValue($request, $response, $matchesVars[$i]), |
||
47 | $message |
||
48 | ); |
||
49 | } |
||
50 | |||
51 | return $message; |
||
52 | } |
||
58 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: