| @@ 1511-1521 (lines=11) @@ | ||
| 1508 | * @return static |
|
| 1509 | * <p>(Immutable)</p> |
|
| 1510 | */ |
|
| 1511 | public function each(\Closure $closure): self |
|
| 1512 | { |
|
| 1513 | // init |
|
| 1514 | $array = []; |
|
| 1515 | ||
| 1516 | foreach ($this->getGenerator() as $key => $value) { |
|
| 1517 | $array[$key] = $closure($value, $key); |
|
| 1518 | } |
|
| 1519 | ||
| 1520 | return static::create( |
|
| 1521 | $array, |
|
| 1522 | $this->iteratorClass, |
|
| 1523 | false |
|
| 1524 | ); |
|
| @@ 3727-3738 (lines=12) @@ | ||
| 3724 | * @return static |
|
| 3725 | * <p>(Immutable)</p> |
|
| 3726 | */ |
|
| 3727 | public function reject(\Closure $closure): self |
|
| 3728 | { |
|
| 3729 | // init |
|
| 3730 | $filtered = []; |
|
| 3731 | ||
| 3732 | foreach ($this->getGenerator() as $key => $value) { |
|
| 3733 | if (!$closure($value, $key)) { |
|
| 3734 | $filtered[$key] = $value; |
|
| 3735 | } |
|
| 3736 | } |
|
| 3737 | ||
| 3738 | return static::create( |
|
| 3739 | $filtered, |
|
| 3740 | $this->iteratorClass, |
|
| 3741 | false |
|