| Conditions | 3 |
| Paths | 3 |
| Total Lines | 22 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | 4 | protected function interpolate(string $template, array $context): string |
|
| 28 | { |
||
| 29 | 4 | $substitutes = []; |
|
| 30 | |||
| 31 | /** |
||
| 32 | * @psalm-suppress MixedAssignment |
||
| 33 | * |
||
| 34 | * $value types are exhaustively checked |
||
| 35 | */ |
||
| 36 | 4 | foreach ($context as $key => $value) { |
|
| 37 | 4 | $placeholder = '{' . $key . '}'; |
|
| 38 | |||
| 39 | 4 | if (strpos($template, $placeholder) === false) { |
|
| 40 | 1 | continue; |
|
| 41 | } |
||
| 42 | |||
| 43 | 4 | $substitutes[$placeholder] = $this->prepare($value, $this->includeTraceback); |
|
| 44 | } |
||
| 45 | |||
| 46 | 4 | $message = strtr($template, $substitutes); |
|
| 47 | |||
| 48 | 4 | return $message; |
|
| 49 | } |
||
| 51 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.