1 | <?php |
||
22 | class Statement |
||
23 | { |
||
24 | /** |
||
25 | * Callables to filter the iterator. |
||
26 | * |
||
27 | * @var callable[] |
||
28 | */ |
||
29 | protected $where = []; |
||
30 | |||
31 | /** |
||
32 | * Callables to sort the iterator. |
||
33 | * |
||
34 | * @var callable[] |
||
35 | */ |
||
36 | protected $order_by = []; |
||
37 | |||
38 | /** |
||
39 | * iterator Offset. |
||
40 | * |
||
41 | * @var int |
||
42 | */ |
||
43 | protected $offset = 0; |
||
44 | |||
45 | /** |
||
46 | * iterator maximum length. |
||
47 | * |
||
48 | * @var int |
||
49 | */ |
||
50 | protected $limit = -1; |
||
51 | |||
52 | /** |
||
53 | * Set the Iterator filter method. |
||
54 | */ |
||
55 | 3 | public function where(callable $callable): self |
|
62 | |||
63 | /** |
||
64 | * Set an Iterator sorting callable function. |
||
65 | */ |
||
66 | 6 | public function orderBy(callable $callable): self |
|
73 | |||
74 | /** |
||
75 | * Set \LimitIterator Offset. |
||
76 | * |
||
77 | * @throws Exception if the offset is lesser than 0 |
||
78 | */ |
||
79 | 18 | public function offset(int $offset): self |
|
94 | |||
95 | /** |
||
96 | * Set \LimitIterator Count. |
||
97 | * |
||
98 | * @throws Exception if the limit is lesser than -1 |
||
99 | */ |
||
100 | 39 | public function limit(int $limit): self |
|
115 | |||
116 | /** |
||
117 | * Execute the prepared Statement on the {@link Reader} object. |
||
118 | * |
||
119 | * @param string[] $header an optional header to use instead of the CSV document header |
||
120 | */ |
||
121 | 27 | public function process(Reader $csv, array $header = []): ResultSet |
|
132 | |||
133 | /** |
||
134 | * Filters elements of an Iterator using a callback function. |
||
135 | */ |
||
136 | 6 | protected function filter(\Iterator $iterator, callable $callable): \CallbackFilterIterator |
|
140 | |||
141 | /** |
||
142 | * Sort the Iterator. |
||
143 | */ |
||
144 | 21 | protected function buildOrderBy(\Iterator $iterator): \Iterator |
|
165 | } |
||
166 |