| Conditions | 9 |
| Paths | 7 |
| Total Lines | 25 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 90 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 25 | public static function make($type, $value) |
||
| 26 | { |
||
| 27 | |||
| 28 | if (is_string($value)) { |
||
| 29 | if ($type === self::MUTABLE_COMPLEX) { |
||
| 30 | return MutableComplexNumber::makeFromString($value); |
||
| 31 | } |
||
| 32 | |||
| 33 | return ImmutableComplexNumber::makeFromString($value); |
||
| 34 | } |
||
| 35 | |||
| 36 | if ($value instanceof NumberCollectionInterface && $value->count() === 2) { |
||
| 37 | if ($type === self::MUTABLE_COMPLEX) { |
||
| 38 | return new MutableComplexNumber($value->get(0), $value->get(1)); |
||
| 39 | } |
||
| 40 | |||
| 41 | return new ImmutableComplexNumber($value->get(0), $value->get(1)); |
||
| 42 | } |
||
| 43 | |||
| 44 | if (is_array($value) && count($value) === 2) { |
||
| 45 | if ($type === self::MUTABLE_COMPLEX) { |
||
| 46 | return new MutableComplexNumber($value[0], $value[1]); |
||
| 47 | } |
||
| 48 | |||
| 49 | return new ImmutableComplexNumber($value[0], $value[1]); |
||
| 50 | } |
||
| 54 | } |