|
@@ 220-230 (lines=11) @@
|
| 217 |
|
* @return \Closure |
| 218 |
|
* @throws \InvalidArgumentException |
| 219 |
|
*/ |
| 220 |
|
public function reducing($name) |
| 221 |
|
{ |
| 222 |
|
// note, once we stop supporting php 5.5, we can rewrite the code below |
| 223 |
|
// to the reducing($name, ...$args) structure. |
| 224 |
|
// http://php.net/manual/en/functions.arguments.php#functions.variable-arg-list |
| 225 |
|
$method = sprintf('\Zicht\Itertools\util\Reductions::%s', $name); |
| 226 |
|
if (!is_callable($method)) { |
| 227 |
|
throw new \InvalidArgumentException(sprintf('$name "%s" is not a valid reduction.', $name)); |
| 228 |
|
} |
| 229 |
|
return call_user_func_array($method, array_slice(func_get_args(), 1)); |
| 230 |
|
} |
| 231 |
|
|
| 232 |
|
/** |
| 233 |
|
* Returns a mapping closure |
|
@@ 242-252 (lines=11) @@
|
| 239 |
|
* @return \Closure |
| 240 |
|
* @throws \InvalidArgumentException |
| 241 |
|
*/ |
| 242 |
|
public function mapping($name) |
| 243 |
|
{ |
| 244 |
|
// note, once we stop supporting php 5.5, we can rewrite the code below |
| 245 |
|
// to the reducing($name, ...$args) structure. |
| 246 |
|
// http://php.net/manual/en/functions.arguments.php#functions.variable-arg-list |
| 247 |
|
$method = sprintf('\Zicht\Itertools\util\Mappings::%s', $name); |
| 248 |
|
if (!is_callable($method)) { |
| 249 |
|
throw new \InvalidArgumentException(sprintf('$name "%s" is not a valid mapping.', $name)); |
| 250 |
|
} |
| 251 |
|
return call_user_func_array($method, array_slice(func_get_args(), 1)); |
| 252 |
|
} |
| 253 |
|
|
| 254 |
|
/** |
| 255 |
|
* Returns a filter closure |
|
@@ 264-275 (lines=12) @@
|
| 261 |
|
* @return \Closure |
| 262 |
|
* @throws \InvalidArgumentException |
| 263 |
|
*/ |
| 264 |
|
public function filtering($name) |
| 265 |
|
{ |
| 266 |
|
// note, once we stop supporting php 5.5, we can rewrite the code below |
| 267 |
|
// to the reducing($name, ...$args) structure. |
| 268 |
|
// http://php.net/manual/en/functions.arguments.php#functions.variable-arg-list |
| 269 |
|
$method = sprintf('\Zicht\Itertools\util\Filters::%s', $name); |
| 270 |
|
if (!is_callable($method)) { |
| 271 |
|
throw new \InvalidArgumentException(sprintf('$name "%s" is not a valid filter.', $name)); |
| 272 |
|
} |
| 273 |
|
return call_user_func_array($method, array_slice(func_get_args(), 1)); |
| 274 |
|
} |
| 275 |
|
|
| 276 |
|
/** |
| 277 |
|
* Make an iterator that returns values from $iterable where the |
| 278 |
|
* $strategy determines that the values are not empty. |