| Conditions | 8 |
| Paths | 7 |
| Total Lines | 14 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | public static function toString($val): string |
||
| 20 | { |
||
| 21 | switch (true) { |
||
| 22 | case \is_string($val): |
||
| 23 | return $val; |
||
| 24 | case \is_bool($val): |
||
| 25 | case \is_float($val): |
||
| 26 | case \is_int($val): |
||
| 27 | case $val === null: |
||
| 28 | return \strval($val); |
||
| 29 | case \is_object($val) && \method_exists($val, '__toString'): |
||
| 30 | return $val->__toString(); |
||
| 31 | default: |
||
| 32 | throw new \InvalidArgumentException('Cannot coerce this value to string'); |
||
| 33 | } |
||
| 36 |