| Conditions | 3 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 27 | public static function new($value, string $toType, array $possibleTypes) : self |
||
| 28 | { |
||
| 29 | $actualType = is_object($value) ? get_class($value) : gettype($value); |
||
| 30 | |||
| 31 | if (is_scalar($value)) { |
||
| 32 | return new self( |
||
| 33 | sprintf( |
||
| 34 | 'Could not convert PHP value "%s" of type "%s" to type "%s". Expected one of the following types: %s.', |
||
| 35 | $value, |
||
| 36 | $actualType, |
||
| 37 | $toType, |
||
| 38 | implode(', ', $possibleTypes) |
||
| 39 | ) |
||
| 40 | ); |
||
| 41 | } |
||
| 42 | |||
| 43 | return new self( |
||
| 44 | sprintf( |
||
| 45 | 'Could not convert PHP value of type "%s" to type "%s". Expected one of the following types: %s.', |
||
| 46 | $actualType, |
||
| 47 | $toType, |
||
| 48 | implode(', ', $possibleTypes) |
||
| 49 | ) |
||
| 53 |