| Total Complexity | 7 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | trait PreparesValue |
||
| 12 | { |
||
| 13 | 5 | public function prepare(mixed $value, bool $includeTraceback, string $tracebackIndent = ''): string |
|
| 14 | { |
||
| 15 | 5 | return match (true) { |
|
| 16 | // Exceptions must be first as they are Stringable |
||
| 17 | 5 | is_object($value) && is_subclass_of($value, Throwable::class) => $this->getExceptionMessage( |
|
| 18 | 5 | $value, |
|
| 19 | 5 | $includeTraceback, |
|
| 20 | 5 | $tracebackIndent |
|
| 21 | 5 | ), |
|
| 22 | 5 | (is_scalar($value) || (is_object($value) && ($value instanceof Stringable))) => (string)$value, |
|
| 23 | 5 | $value instanceof DateTimeInterface => $value->format('Y-m-d H:i:s T'), |
|
| 24 | 5 | is_object($value) => '[Instance of ' . $value::class . ']', |
|
| 25 | 5 | is_array($value) => '[Array ' . json_encode($value, JSON_UNESCAPED_SLASHES) . ']', |
|
| 26 | 5 | is_null($value) => '[null]', |
|
| 27 | 5 | default => '[' . get_debug_type($value) . ']', |
|
| 28 | 5 | }; |
|
| 29 | } |
||
| 30 | |||
| 31 | 2 | protected function getExceptionMessage( |
|
| 49 | } |
||
| 50 | } |
||
| 51 |