| @@ 1516-1526 (lines=11) @@ | ||
| 1513 | * @return static |
|
| 1514 | * <p>(Immutable)</p> |
|
| 1515 | */ |
|
| 1516 | public function each(\Closure $closure): self |
|
| 1517 | { |
|
| 1518 | // init |
|
| 1519 | $array = []; |
|
| 1520 | ||
| 1521 | foreach ($this->getGenerator() as $key => $value) { |
|
| 1522 | $array[$key] = $closure($value, $key); |
|
| 1523 | } |
|
| 1524 | ||
| 1525 | return static::create( |
|
| 1526 | $array, |
|
| 1527 | $this->iteratorClass, |
|
| 1528 | false |
|
| 1529 | ); |
|
| @@ 3742-3753 (lines=12) @@ | ||
| 3739 | * @return static |
|
| 3740 | * <p>(Immutable)</p> |
|
| 3741 | */ |
|
| 3742 | public function reject(\Closure $closure): self |
|
| 3743 | { |
|
| 3744 | // init |
|
| 3745 | $filtered = []; |
|
| 3746 | ||
| 3747 | foreach ($this->getGenerator() as $key => $value) { |
|
| 3748 | if (!$closure($value, $key)) { |
|
| 3749 | $filtered[$key] = $value; |
|
| 3750 | } |
|
| 3751 | } |
|
| 3752 | ||
| 3753 | return static::create( |
|
| 3754 | $filtered, |
|
| 3755 | $this->iteratorClass, |
|
| 3756 | false |
|