| Total Complexity | 7 |
| Total Lines | 95 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | trait TraitBitrixLoader |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Список полей для выборки |
||
| 9 | * |
||
| 10 | * @var array |
||
| 11 | */ |
||
| 12 | protected $select = []; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Порядок сортировки данных |
||
| 16 | * |
||
| 17 | * @var array |
||
| 18 | */ |
||
| 19 | protected $sort = []; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Правила фильтрации данных |
||
| 23 | * |
||
| 24 | * @var array |
||
| 25 | */ |
||
| 26 | protected $filter = []; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Имя репозитория |
||
| 30 | * |
||
| 31 | * @var string |
||
| 32 | */ |
||
| 33 | protected $nameRepository; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Название поля используемое как ключ |
||
| 37 | * |
||
| 38 | * @var string |
||
| 39 | */ |
||
| 40 | protected $key = 'ID'; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Выборка полей |
||
| 44 | * |
||
| 45 | * @param array $select |
||
| 46 | * @return TraitBitrixLoader |
||
| 47 | */ |
||
| 48 | public function select(array $select): self |
||
| 49 | { |
||
| 50 | $this->select = $select; |
||
| 51 | return $this; |
||
| 52 | } |
||
| 53 | |||
| 54 | public function setKey(string $key): self |
||
| 55 | { |
||
| 56 | $this->key = $key; |
||
| 57 | return $this; |
||
| 58 | } |
||
| 59 | |||
| 60 | private function getKey(): string |
||
| 61 | { |
||
| 62 | return (string) $this->key; |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Сортировка данных |
||
| 67 | * ["field"=>"asc|desc"] |
||
| 68 | * |
||
| 69 | * @param array $sort |
||
| 70 | * @return TraitBitrixLoader |
||
| 71 | */ |
||
| 72 | public function sort(array $sort): self |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * Фильтрация данных |
||
| 80 | * |
||
| 81 | * @param array $filter |
||
| 82 | * @return TraitBitrixLoader |
||
| 83 | */ |
||
| 84 | public function filter(array $filter): self |
||
| 85 | { |
||
| 86 | $this->filter = $filter; |
||
| 87 | return $this; |
||
| 88 | } |
||
| 89 | |||
| 90 | private function repositoryName(string $key): string |
||
| 97 | } |
||
| 98 | |||
| 99 | abstract public static function getRepositoryName(string $key): string; |
||
| 100 | } |
||
| 101 |