1 | <?php |
||
26 | class Statement |
||
27 | { |
||
28 | /** |
||
29 | * Callables to filter the iterator. |
||
30 | * |
||
31 | * @var callable[] |
||
32 | */ |
||
33 | protected $where = []; |
||
34 | |||
35 | /** |
||
36 | * Callables to sort the iterator. |
||
37 | * |
||
38 | * @var callable[] |
||
39 | */ |
||
40 | protected $order_by = []; |
||
41 | |||
42 | /** |
||
43 | * iterator Offset. |
||
44 | * |
||
45 | * @var int |
||
46 | */ |
||
47 | protected $offset = 0; |
||
48 | |||
49 | /** |
||
50 | * iterator maximum length. |
||
51 | * |
||
52 | * @var int |
||
53 | */ |
||
54 | protected $limit = -1; |
||
55 | |||
56 | /** |
||
57 | * Set the Iterator filter method. |
||
58 | */ |
||
59 | 3 | public function where(callable $callable): self |
|
66 | |||
67 | /** |
||
68 | * Set an Iterator sorting callable function. |
||
69 | */ |
||
70 | 6 | public function orderBy(callable $callable): self |
|
77 | |||
78 | /** |
||
79 | * Set LimitIterator Offset. |
||
80 | * |
||
81 | * @throws Exception if the offset is lesser than 0 |
||
82 | */ |
||
83 | 18 | public function offset(int $offset): self |
|
98 | |||
99 | /** |
||
100 | * Set LimitIterator Count. |
||
101 | * |
||
102 | * @throws Exception if the limit is lesser than -1 |
||
103 | */ |
||
104 | 39 | public function limit(int $limit): self |
|
119 | |||
120 | /** |
||
121 | * Execute the prepared Statement on the {@link Reader} object. |
||
122 | * |
||
123 | * @param string[] $header an optional header to use instead of the CSV document header |
||
124 | */ |
||
125 | 27 | public function process(Reader $csv, array $header = []): ResultSet |
|
136 | |||
137 | /** |
||
138 | * Filters elements of an Iterator using a callback function. |
||
139 | */ |
||
140 | 6 | protected function filter(Iterator $iterator, callable $callable): CallbackFilterIterator |
|
144 | |||
145 | /** |
||
146 | * Sort the Iterator. |
||
147 | */ |
||
148 | 21 | protected function buildOrderBy(Iterator $iterator): Iterator |
|
169 | } |
||
170 |