Conditions | 9 |
Paths | 6 |
Total Lines | 27 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 9.0294 |
Changes | 0 |
1 | <?php |
||
46 | 10 | public function process($value) |
|
47 | { |
||
48 | 10 | if ($value instanceof Immutable\StreamInterface && (string) $value->type() === $this->type) { |
|
49 | 1 | if ($this->requiresValue && $value->size() === 0) { |
|
50 | 1 | throw new InvalidArgumentException; |
|
51 | } |
||
52 | |||
53 | return $value; |
||
54 | } |
||
55 | |||
56 | 9 | if ($value instanceof Immutable\StreamInterface) { |
|
57 | 1 | throw new InvalidArgumentException; |
|
58 | } |
||
59 | |||
60 | 8 | $value = $value ?? []; |
|
61 | |||
62 | 8 | if (!is_array($value)) { |
|
63 | 2 | throw new InvalidArgumentException; |
|
64 | } |
||
65 | |||
66 | 6 | $stream = Immutable\Stream::of($this->type, ...$value); |
|
67 | |||
68 | 6 | if ($this->requiresValue && $stream->size() === 0) { |
|
69 | 2 | throw new InvalidArgumentException; |
|
70 | } |
||
71 | |||
72 | 4 | return $stream; |
|
73 | } |
||
75 |