Total Complexity | 10 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
9 | final class AnyToString |
||
10 | { |
||
11 | public function __invoke($any): string |
||
12 | { |
||
13 | return is_object($any) |
||
14 | ? $this->objectToString($any) |
||
15 | : $this->valueToString($any); |
||
16 | } |
||
17 | |||
18 | private function objectToString($object): string |
||
19 | { |
||
20 | $ro = new \ReflectionObject($object); |
||
21 | |||
22 | if ($ro->hasMethod('toString')) { |
||
23 | return $object->toString(); |
||
24 | } |
||
25 | |||
26 | if ($ro->hasMethod('__toString')) { |
||
27 | return (string) $object; |
||
28 | } |
||
29 | |||
30 | return spl_object_hash($object); |
||
31 | } |
||
32 | |||
33 | private function valueToString($value): string |
||
34 | { |
||
35 | $conversion = $this->implicitConversionFor($value); |
||
36 | |||
37 | return ($conversion !== '') |
||
38 | ? $conversion($value) |
||
39 | : (string) $value; |
||
40 | } |
||
41 | |||
42 | private function implicitConversionFor($any): string |
||
53 | } |
||
54 | } |
||
55 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths