Conditions | 4 |
Paths | 4 |
Total Lines | 20 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
29 | public static function valueOutOfRange($value): self |
||
30 | { |
||
31 | if (!is_object($value)) { |
||
32 | return new self( |
||
33 | sprintf('Collection does not contain the value %s(%s)', gettype($value), print_r($value, true)) |
||
34 | ); |
||
35 | } |
||
36 | |||
37 | if (method_exists($value, 'toString')) { |
||
38 | $representation = $value->toString(); |
||
39 | } elseif (method_exists($value, '__toString')) { |
||
40 | $representation = (string) $value; |
||
41 | } else { |
||
42 | $representation = spl_object_hash($value); |
||
43 | } |
||
44 | |||
45 | return new self( |
||
46 | sprintf('Collection does not contain the value %s(%s)', get_class($value), $representation) |
||
47 | ); |
||
48 | } |
||
49 | } |
||
50 |