1 | <?php |
||
21 | abstract class DataSource implements DataSourceInterface |
||
22 | { |
||
23 | /** |
||
24 | * @var SpecificationInterface |
||
25 | */ |
||
26 | protected $searchCriteria; |
||
27 | |||
28 | /** |
||
29 | * @var ComparatorInterface |
||
30 | */ |
||
31 | protected $sortCriteria; |
||
32 | |||
33 | /** |
||
34 | * @var int |
||
35 | */ |
||
36 | protected $offset; |
||
37 | |||
38 | /** |
||
39 | * @var int |
||
40 | */ |
||
41 | protected $length; |
||
42 | |||
43 | /** |
||
44 | * @var int |
||
45 | */ |
||
46 | private $count; |
||
47 | |||
48 | /** |
||
49 | * @param SpecificationInterface $searchCriteria |
||
50 | * @param ComparatorInterface $sortCriteria |
||
51 | * @param int $offset |
||
52 | * @param int $length |
||
53 | */ |
||
54 | public function __construct( |
||
65 | |||
66 | /** |
||
67 | * {@inheritdoc} |
||
68 | */ |
||
69 | public function count() |
||
77 | |||
78 | /** |
||
79 | * {@inheritdoc} |
||
80 | */ |
||
81 | public function length() |
||
85 | |||
86 | /** |
||
87 | * {@inheritdoc} |
||
88 | */ |
||
89 | public function offset() |
||
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | */ |
||
97 | public function searchCriteria() |
||
101 | |||
102 | /** |
||
103 | * {@inheritdoc} |
||
104 | */ |
||
105 | public function sortCriteria() |
||
109 | |||
110 | /** |
||
111 | * @return bool |
||
112 | */ |
||
113 | public function isSorted() |
||
117 | |||
118 | /** |
||
119 | * @return bool |
||
120 | */ |
||
121 | public function isFiltered() |
||
125 | |||
126 | /** |
||
127 | * @return bool |
||
128 | */ |
||
129 | public function isSliced() |
||
133 | |||
134 | /** |
||
135 | * @param int $offset |
||
136 | */ |
||
137 | protected function actualOffset($offset) |
||
146 | |||
147 | /** |
||
148 | * @param int $offset |
||
149 | * @param int $length |
||
150 | */ |
||
151 | protected function actualLength($offset, $length = null) |
||
168 | |||
169 | /** |
||
170 | * @return int |
||
171 | */ |
||
172 | abstract protected function calculateCount(); |
||
173 | } |
||
174 |