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