| Conditions | 9 |
| Paths | 9 |
| Total Lines | 40 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 20 |
| CRAP Score | 9 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 25 | 272 | protected static function valueToString(mixed $value): string |
|
| 26 | { |
||
| 27 | 272 | if (null === $value) { |
|
| 28 | 2 | return 'null'; |
|
| 29 | } |
||
| 30 | |||
| 31 | 270 | if (true === $value) { |
|
| 32 | 2 | return 'true'; |
|
| 33 | } |
||
| 34 | |||
| 35 | 268 | if (false === $value) { |
|
| 36 | 2 | return 'false'; |
|
| 37 | } |
||
| 38 | |||
| 39 | 266 | if (is_array($value)) { |
|
| 40 | 4 | return 'array'; |
|
| 41 | } |
||
| 42 | |||
| 43 | 262 | if (is_object($value)) { |
|
| 44 | 4 | if (method_exists($value, '__toString')) { |
|
| 45 | 2 | $format = '%1$s: %2$s'; |
|
| 46 | |||
| 47 | 2 | return sprintf($format, $value::class, self::valueToString($value->__toString())); |
|
| 48 | } |
||
| 49 | |||
| 50 | 2 | return $value::class; |
|
| 51 | } |
||
| 52 | |||
| 53 | 260 | if (is_resource($value)) { |
|
| 54 | 2 | return 'resource'; |
|
| 55 | } |
||
| 56 | |||
| 57 | 258 | if (is_string($value)) { |
|
| 58 | 230 | $format = '"%1$s"'; |
|
| 59 | |||
| 60 | 230 | return sprintf($format, $value); |
|
| 61 | } |
||
| 62 | |||
| 63 | // @phpstan-ignore-next-line |
||
| 64 | 76 | return (string) $value; |
|
| 65 | } |
||
| 67 |