| Conditions | 3 |
| Paths | 3 |
| Total Lines | 9 |
| Code Lines | 5 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 30 | 2 | public static function createFromString(string $string): self |
|
| 31 | { |
||
| 32 | 2 | if (filter_var($string, FILTER_VALIDATE_INT) !== false) { |
|
| 33 | 1 | return new static((int)$string); |
|
|
|
|||
| 34 | } |
||
| 35 | 2 | if (is_numeric($string)) { |
|
| 36 | 1 | return new static((float)$string); |
|
| 37 | } |
||
| 38 | 1 | throw new InvalidVOArgumentException('Value is invalid. Allowed type is integer, float, double, real', $string); |
|
| 39 | } |
||
| 41 |