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