1 | <?php |
||
17 | class Sort implements SortInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var array |
||
21 | */ |
||
22 | protected $properties; |
||
23 | |||
24 | /** |
||
25 | * @var Order |
||
26 | */ |
||
27 | protected $order; |
||
28 | |||
29 | /** |
||
30 | * Creates a new Sort instance using the given Order. |
||
31 | * |
||
32 | * @param array $properties |
||
33 | * @param OrderInterface $order |
||
34 | */ |
||
35 | public function __construct(array $properties = [], OrderInterface $order = null) |
||
40 | |||
41 | /** |
||
42 | * @param OrderInterface|null $order |
||
43 | * |
||
44 | * @return OrderInterface |
||
45 | */ |
||
46 | protected function setOrder(OrderInterface $order = null) |
||
53 | |||
54 | /** |
||
55 | * Returns a new Sort consisting of the orders of the current Sort combined with the given ones. |
||
56 | * |
||
57 | * @param SortInterface $sort |
||
58 | * |
||
59 | * @return SortInterface |
||
60 | */ |
||
61 | public function andSort(SortInterface $sort) |
||
67 | |||
68 | /** |
||
69 | * @return array |
||
70 | */ |
||
71 | public function orders() |
||
72 | { |
||
73 | return $this->properties; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * @param array $properties |
||
78 | */ |
||
79 | protected function setProperties(array $properties) |
||
86 | |||
87 | /** |
||
88 | * @param SortInterface $sort |
||
89 | * |
||
90 | * @return bool |
||
91 | */ |
||
92 | public function equals(SortInterface $sort) |
||
96 | |||
97 | /** |
||
98 | * Returns the order registered for the given property. |
||
99 | * |
||
100 | * @param string $propertyName |
||
101 | * |
||
102 | * @return Order |
||
103 | */ |
||
104 | public function orderFor($propertyName) |
||
105 | { |
||
106 | $this->hasProperty($propertyName); |
||
107 | |||
108 | return $this->properties[$propertyName]; |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * @param $propertyName |
||
113 | * |
||
114 | * @throws \InvalidArgumentException |
||
115 | */ |
||
116 | protected function hasProperty($propertyName) |
||
122 | |||
123 | /** |
||
124 | * @param $propertyName |
||
125 | * @param OrderInterface $order |
||
126 | */ |
||
127 | public function setOrderFor($propertyName, OrderInterface $order) |
||
131 | |||
132 | /** |
||
133 | * @param string $propertyName |
||
134 | * |
||
135 | * @return OrderInterface |
||
136 | * |
||
137 | * @throws \InvalidArgumentException |
||
138 | */ |
||
139 | public function property($propertyName) |
||
145 | } |
||
146 |