| Conditions | 5 | 
| Paths | 3 | 
| Total Lines | 11 | 
| Code Lines | 5 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 6 | 
| CRAP Score | 5 | 
| Changes | 0 | ||
| 1 | <?php  | 
            ||
| 40 | 81 | protected function tryCast($value): ?string  | 
            |
| 41 |     { | 
            ||
| 42 | 81 |         if ($value === null) { | 
            |
| 43 | 7 | return null;  | 
            |
| 44 | }  | 
            ||
| 45 | |||
| 46 | 79 |         if (!is_scalar($value) && (!is_object($value) || !method_exists($value, '__toString'))) { | 
            |
| 47 | 3 |             throw new TypeError('The import()\'ed value of a '.static::class.' must be stringable or null'); | 
            |
| 48 | }  | 
            ||
| 49 | |||
| 50 | 76 | return (string) $value;  | 
            |
| 51 | }  | 
            ||
| 53 | 
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: