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