1 | <?php |
||
11 | final class SortComponent implements ComponentInterface, IteratorAggregate, Countable, JsonSerializable |
||
12 | { |
||
13 | /** |
||
14 | * @var Sort[] |
||
15 | */ |
||
16 | private $sorts = []; |
||
17 | |||
18 | /** |
||
19 | * SortComponent constructor. |
||
20 | * @param array $sorts |
||
21 | */ |
||
22 | public function __construct(array $sorts) |
||
28 | |||
29 | /** |
||
30 | * @param Sort $sort |
||
31 | */ |
||
32 | public function add(Sort $sort): void |
||
36 | |||
37 | /** |
||
38 | * @param string $field |
||
39 | * @param null $direction |
||
40 | * @return bool |
||
41 | */ |
||
42 | public function has(string $field, $direction = null): bool |
||
62 | |||
63 | /** |
||
64 | * @param string $field |
||
65 | * @param null $direction |
||
66 | * @return Sort[] |
||
67 | */ |
||
68 | public function get(string $field, $direction = null): iterable |
||
86 | |||
87 | /** |
||
88 | * @return Sort[] |
||
89 | */ |
||
90 | public function all(): array |
||
94 | |||
95 | /** |
||
96 | * @return Sort[] |
||
97 | */ |
||
98 | public function getAppliedSorts(): array |
||
109 | |||
110 | /** |
||
111 | * @return Sort[] |
||
112 | */ |
||
113 | public function getIterator(): iterable |
||
117 | |||
118 | /** |
||
119 | * @inheritDoc |
||
120 | */ |
||
121 | public function count(): int |
||
125 | |||
126 | /** |
||
127 | * @inheritDoc |
||
128 | */ |
||
129 | public static function getName(): string |
||
133 | |||
134 | /** |
||
135 | * @param string $field |
||
136 | * @param string|null $direction |
||
137 | * @return bool |
||
138 | */ |
||
139 | public function isApplied(string $field, ?string $direction = null): bool |
||
159 | |||
160 | /** |
||
161 | * @inheritDoc |
||
162 | */ |
||
163 | public function jsonSerialize(): array |
||
198 | } |
||
199 |