| Total Complexity | 6 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 10 | trait FilteredTrait |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @param array $filter |
||
| 14 | * @return ApiResponse |
||
| 15 | */ |
||
| 16 | 2 | public function getFiltered(array $filter = []): ApiResponse |
|
| 17 | { |
||
| 18 | 2 | $add_params = ''; |
|
| 19 | 2 | if (!empty($filter)) { |
|
| 20 | 2 | $filtered = []; |
|
| 21 | 2 | foreach ($filter as $k => $v) { |
|
| 22 | 2 | if (array_key_exists($k, Constants::OFFICE_FILTER)) { |
|
| 23 | 2 | $filtered[$k] = $v; |
|
| 24 | } |
||
| 25 | } |
||
| 26 | 2 | $filter = array_replace(Constants::OFFICE_FILTER, $filtered); |
|
| 27 | 2 | $add_params = empty($filter) ? '' : http_build_query($filter); |
|
| 28 | } |
||
| 29 | 2 | return $this->get($add_params); |
|
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Переиспользуем стандартный метод |
||
| 34 | * @param string $filter |
||
| 35 | * @return ApiResponse |
||
| 36 | */ |
||
| 37 | 4 | public function get(string $filter = ''): ApiResponse |
|
| 40 | } |
||
| 41 | } |
||
| 42 |