1 | <?php |
||
19 | class TabularCollection extends MultiCollection |
||
20 | { |
||
21 | /** |
||
22 | * Tabular Where Search. |
||
23 | * |
||
24 | * Search for values of a certain key that meet a particular search criteria |
||
25 | * using either one of the "Collection\Criteria::" class constants, or its string |
||
26 | * counterpart. |
||
27 | * |
||
28 | * Warning: Only works for tabular collections (2-dimensional data array) |
||
29 | * |
||
30 | * @param string $key The key to compare to $val |
||
31 | * @param mixed|Callable $val Either a value to test against or a callable to |
||
32 | * run your own custom "where comparison logic" |
||
33 | * @param string $comp The type of comparison operation ot use (such as "==" |
||
34 | * or "instanceof"). Must be one of the self::* constants' values |
||
35 | * listed at the top of this class. |
||
36 | * @return TabularCollection A collection of rows that meet the criteria |
||
37 | * specified by $key, $val, and $comp |
||
38 | */ |
||
39 | 1 | public function where($key, $val, $comp = null) |
|
107 | |||
108 | /** |
||
109 | * Magic method call. |
||
110 | * |
||
111 | * @param string $method The name of the method |
||
112 | * @param array $args The argument list |
||
113 | * |
||
114 | * @throws BadMethodCallException If no method exists |
||
115 | * |
||
116 | * @return mixed |
||
117 | * |
||
118 | * @todo Add phpdoc comments for dynamic methods |
||
119 | * @todo throw BadMethodCallException |
||
120 | */ |
||
121 | 8 | public function __call($method, $args) |
|
132 | |||
133 | /** |
||
134 | * Does this collection have specified column? |
||
135 | * |
||
136 | * @param mixed $column The column index |
||
137 | * |
||
138 | * @return bool |
||
139 | */ |
||
140 | 9 | public function hasColumn($column) |
|
150 | |||
151 | /** |
||
152 | * Get column as collection. |
||
153 | * |
||
154 | * @param mixed $column The column index |
||
155 | * @param bool $throw Throw an exception on failure |
||
156 | * |
||
157 | * @return AbstractCollection|false |
||
158 | */ |
||
159 | 10 | public function getColumn($column, $throw = true) |
|
171 | |||
172 | /** |
||
173 | * Does this collection have a row at specified index? |
||
174 | * |
||
175 | * @param int $offset The column index |
||
176 | * |
||
177 | * @return bool |
||
178 | */ |
||
179 | 1 | public function hasRow($offset) |
|
189 | |||
190 | /** |
||
191 | * Get row at specified index. |
||
192 | * |
||
193 | * @param int $offset The row offset (starts from 0) |
||
194 | * |
||
195 | * @return AbstractCollection|false |
||
196 | */ |
||
197 | 3 | public function getRow($offset) |
|
201 | |||
202 | /** |
||
203 | * {@inheritdoc} |
||
204 | */ |
||
205 | 1 | public function map(callable $callback) |
|
214 | |||
215 | /** |
||
216 | * {@inheritdoc} |
||
217 | */ |
||
218 | 21 | public function walk(callable $callback, $extraContext = null) |
|
226 | |||
227 | /** |
||
228 | * Is input data structure valid? |
||
229 | * |
||
230 | * In order to determine whether a given data structure is valid for a |
||
231 | * particular collection type (tabular, numeric, etc.), we have this method. |
||
232 | * |
||
233 | * @param mixed $data The data structure to check |
||
234 | * |
||
235 | * @return bool True if data structure is tabular |
||
236 | */ |
||
237 | 44 | protected function isConsistentDataStructure($data) |
|
241 | } |
||
242 |