| Conditions | 6 |
| Paths | 5 |
| Total Lines | 16 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 7.3329 |
| Changes | 0 | ||
| 1 | <?php |
||
| 48 | 4 | public function withFiltersArray(array $filtersArray) |
|
| 49 | { |
||
| 50 | 4 | foreach ($filtersArray as $key => $filter) { |
|
| 51 | 4 | if ($filter instanceof FilterInterface) { |
|
| 52 | continue; |
||
| 53 | 4 | } elseif (!is_array($filter)) { |
|
| 54 | 1 | throw new \RuntimeException(sprintf('Invalid filter at "%s" key', $key)); |
|
| 55 | } |
||
| 56 | 3 | $first = array_shift($filter); |
|
| 57 | 3 | if (!is_string($first) || !strlen($first)) { |
|
| 58 | 3 | throw new \RuntimeException(sprintf('Invalid filter operator on "%s" key', $key)); |
|
| 59 | } |
||
| 60 | } |
||
| 61 | $new = clone $this; |
||
| 62 | $new->filters = $filtersArray; |
||
| 63 | return $new; |
||
| 64 | } |
||
| 66 |