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 |
||
32 | 272 | protected static function valueToString($value): string |
|
33 | { |
||
34 | 272 | if (null === $value) { |
|
35 | 2 | return 'null'; |
|
36 | } |
||
37 | |||
38 | 270 | if (true === $value) { |
|
39 | 2 | return 'true'; |
|
40 | } |
||
41 | |||
42 | 268 | if (false === $value) { |
|
43 | 2 | return 'false'; |
|
44 | } |
||
45 | |||
46 | 266 | if (is_array($value)) { |
|
47 | 4 | return 'array'; |
|
48 | } |
||
49 | |||
50 | 262 | if (is_object($value)) { |
|
51 | 4 | if (method_exists($value, '__toString')) { |
|
52 | 2 | $format = '%1$s: %2$s'; |
|
53 | |||
54 | 2 | return sprintf($format, get_class($value), self::valueToString($value->__toString())); |
|
55 | } |
||
56 | |||
57 | 2 | return get_class($value); |
|
58 | } |
||
59 | |||
60 | 260 | if (is_resource($value)) { |
|
61 | 2 | return 'resource'; |
|
62 | } |
||
63 | |||
64 | 258 | if (is_string($value)) { |
|
65 | 230 | $format = '"%1$s"'; |
|
66 | |||
67 | 230 | return sprintf($format, $value); |
|
68 | } |
||
69 | |||
70 | // @phpstan-ignore-next-line |
||
71 | 76 | return (string) $value; |
|
72 | } |
||
74 |