@@ 213-223 (lines=11) @@ | ||
210 | * @return \Closure |
|
211 | * @throws \InvalidArgumentException |
|
212 | */ |
|
213 | public function reducing($name) |
|
214 | { |
|
215 | // note, once we stop supporting php 5.5, we can rewrite the code below |
|
216 | // to the reducing($name, ...$args) structure. |
|
217 | // http://php.net/manual/en/functions.arguments.php#functions.variable-arg-list |
|
218 | $method = sprintf('\Zicht\Itertools\util\Reductions::%s', $name); |
|
219 | if (!is_callable($method)) { |
|
220 | throw new \InvalidArgumentException(sprintf('$name "%s" is not a valid reduction.', $name)); |
|
221 | } |
|
222 | return call_user_func_array($method, array_slice(func_get_args(), 1)); |
|
223 | } |
|
224 | ||
225 | /** |
|
226 | * Returns a mapping closure |
|
@@ 235-245 (lines=11) @@ | ||
232 | * @return \Closure |
|
233 | * @throws \InvalidArgumentException |
|
234 | */ |
|
235 | public function mapping($name) |
|
236 | { |
|
237 | // note, once we stop supporting php 5.5, we can rewrite the code below |
|
238 | // to the reducing($name, ...$args) structure. |
|
239 | // http://php.net/manual/en/functions.arguments.php#functions.variable-arg-list |
|
240 | $method = sprintf('\Zicht\Itertools\util\Mappings::%s', $name); |
|
241 | if (!is_callable($method)) { |
|
242 | throw new \InvalidArgumentException(sprintf('$name "%s" is not a valid mapping.', $name)); |
|
243 | } |
|
244 | return call_user_func_array($method, array_slice(func_get_args(), 1)); |
|
245 | } |
|
246 | ||
247 | /** |
|
248 | * Returns a filter closure |
|
@@ 257-268 (lines=12) @@ | ||
254 | * @return \Closure |
|
255 | * @throws \InvalidArgumentException |
|
256 | */ |
|
257 | public function filtering($name) |
|
258 | { |
|
259 | // note, once we stop supporting php 5.5, we can rewrite the code below |
|
260 | // to the reducing($name, ...$args) structure. |
|
261 | // http://php.net/manual/en/functions.arguments.php#functions.variable-arg-list |
|
262 | $method = sprintf('\Zicht\Itertools\util\Filters::%s', $name); |
|
263 | if (!is_callable($method)) { |
|
264 | throw new \InvalidArgumentException(sprintf('$name "%s" is not a valid filter.', $name)); |
|
265 | } |
|
266 | return call_user_func_array($method, array_slice(func_get_args(), 1)); |
|
267 | ||
268 | } |
|
269 | ||
270 | /** |
|
271 | * Make an iterator that returns values from $iterable where the |