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