| Total Complexity | 5 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class ContextFormatter implements Formatter |
||
| 11 | { |
||
| 12 | use PreparesValue; |
||
| 13 | |||
| 14 | 1 | public function __construct(protected readonly bool $includeTraceback = true) |
|
| 16 | 1 | } |
|
| 17 | |||
| 18 | 1 | public function format(string $message, ?array $context): string |
|
| 19 | { |
||
| 20 | 1 | if ($context) { |
|
|
|
|||
| 21 | 1 | return $message . ":\n" . $this->transform($context); |
|
| 22 | } |
||
| 23 | |||
| 24 | 1 | return $message; |
|
| 25 | } |
||
| 26 | |||
| 27 | 1 | protected function transform(array $context): string |
|
| 41 | } |
||
| 42 | } |
||
| 43 |
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.