| Total Complexity | 7 |
| Total Lines | 80 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | abstract class FilterDynamic implements Filter |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var Builder |
||
| 12 | */ |
||
| 13 | protected $query; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | protected $column = 'id'; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Apply a given search value to the builder instance. |
||
| 22 | * |
||
| 23 | * - if a 'string' value is found then a single value where clause is added |
||
| 24 | * - if a 'array' value is found then a whereIn clause is added |
||
| 25 | * |
||
| 26 | * @param Builder $query |
||
| 27 | * @param mixed $value |
||
| 28 | * @return Builder $query |
||
| 29 | */ |
||
| 30 | public function apply(Builder $query, $value = null) |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Add a where clause that searches for a single value. |
||
| 56 | * |
||
| 57 | * @param string $id |
||
| 58 | * @return Builder |
||
| 59 | */ |
||
| 60 | protected function stringValueClause($id) |
||
| 61 | { |
||
| 62 | $this->query->whereIn($this->column, (array) $id); |
||
| 63 | |||
| 64 | return $this->query; |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Add a where clause that searches for an array of values. |
||
| 69 | * |
||
| 70 | * @param array $ids |
||
| 71 | * @return Builder |
||
| 72 | */ |
||
| 73 | protected function arrayValueClause(array $ids) |
||
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * Set the Query Builder property. |
||
| 82 | * |
||
| 83 | * @param Builder $query |
||
| 84 | */ |
||
| 85 | private function setQuery(Builder $query): void |
||
| 90 |