| @@ 666-681 (lines=16) @@ | ||
| 663 | * @param callable $callback |
|
| 664 | * @return ArrayList |
|
| 665 | */ |
|
| 666 | public function filterByCallback($callback) |
|
| 667 | { |
|
| 668 | if (!is_callable($callback)) { |
|
| 669 | throw new LogicException(sprintf( |
|
| 670 | "SS_Filterable::filterByCallback() passed callback must be callable, '%s' given", |
|
| 671 | gettype($callback) |
|
| 672 | )); |
|
| 673 | } |
|
| 674 | ||
| 675 | $output = static::create(); |
|
| 676 | ||
| 677 | foreach ($this as $item) { |
|
| 678 | if (call_user_func($callback, $item, $this)) { |
|
| 679 | $output->push($item); |
|
| 680 | } |
|
| 681 | } |
|
| 682 | ||
| 683 | return $output; |
|
| 684 | } |
|
| @@ 497-512 (lines=16) @@ | ||
| 494 | * @param callable $callback |
|
| 495 | * @return ArrayList (this may change in future implementations) |
|
| 496 | */ |
|
| 497 | public function filterByCallback($callback) |
|
| 498 | { |
|
| 499 | if (!is_callable($callback)) { |
|
| 500 | throw new LogicException(sprintf( |
|
| 501 | "SS_Filterable::filterByCallback() passed callback must be callable, '%s' given", |
|
| 502 | gettype($callback) |
|
| 503 | )); |
|
| 504 | } |
|
| 505 | /** @var ArrayList $output */ |
|
| 506 | $output = ArrayList::create(); |
|
| 507 | foreach ($this as $item) { |
|
| 508 | if (call_user_func($callback, $item, $this)) { |
|
| 509 | $output->push($item); |
|
| 510 | } |
|
| 511 | } |
|
| 512 | return $output; |
|
| 513 | } |
|
| 514 | ||
| 515 | /** |
|
| @@ 230-242 (lines=13) @@ | ||
| 227 | * @param callable $callback |
|
| 228 | * @return ArrayList (this may change in future implementations) |
|
| 229 | */ |
|
| 230 | public function filterByCallback($callback) |
|
| 231 | { |
|
| 232 | if (!is_callable($callback)) { |
|
| 233 | throw new LogicException(sprintf( |
|
| 234 | "SS_Filterable::filterByCallback() passed callback must be callable, '%s' given", |
|
| 235 | gettype($callback) |
|
| 236 | )); |
|
| 237 | } |
|
| 238 | $output = ArrayList::create(); |
|
| 239 | foreach ($this->list as $item) { |
|
| 240 | if (call_user_func($callback, $item, $this->list)) { |
|
| 241 | $output->push($item); |
|
| 242 | } |
|
| 243 | } |
|
| 244 | return $output; |
|
| 245 | } |
|