| Conditions | 9 |
| Paths | 7 |
| Total Lines | 29 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 9 |
| Changes | 0 | ||
| 1 | <?php |
||
| 37 | 11 | public function process($value) |
|
| 38 | { |
||
| 39 | 11 | if (is_null($value)) { |
|
| 40 | 2 | if ($this->requiresValue) { |
|
| 41 | 1 | throw new InvalidArgumentException; |
|
| 42 | } |
||
| 43 | |||
| 44 | 1 | return new Immutable\Sequence; |
|
| 45 | } |
||
| 46 | |||
| 47 | 9 | if ($value instanceof Immutable\Sequence) { |
|
| 48 | 4 | if ($this->requiresValue && $value->size() === 0) { |
|
| 49 | 1 | throw new InvalidArgumentException; |
|
| 50 | } |
||
| 51 | |||
| 52 | 3 | return $value; |
|
| 53 | } |
||
| 54 | |||
| 55 | 5 | if (!is_array($value)) { |
|
| 56 | 1 | throw new InvalidArgumentException; |
|
| 57 | } |
||
| 58 | |||
| 59 | 4 | $sequence = Immutable\Sequence::of(...$value); |
|
| 60 | |||
| 61 | 4 | if ($this->requiresValue && $sequence->size() === 0) { |
|
| 62 | 1 | throw new InvalidArgumentException; |
|
| 63 | } |
||
| 64 | |||
| 65 | 3 | return $sequence; |
|
| 66 | } |
||
| 68 |