| Conditions | 5 |
| Paths | 3 |
| Total Lines | 11 |
| Code Lines | 5 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 44 | 82 | protected function tryCast($value): ?string |
|
| 45 | { |
||
| 46 | 82 | if ($value === null) { |
|
| 47 | 7 | return null; |
|
| 48 | } |
||
| 49 | |||
| 50 | 80 | if (!is_scalar($value) && (!is_object($value) || !method_exists($value, '__toString'))) { |
|
| 51 | 3 | throw new TypeError('The import()\'ed value of a '.static::class.' must be stringable or null'); |
|
| 52 | } |
||
| 53 | |||
| 54 | 77 | return (string) $value; |
|
| 55 | } |
||
| 57 |