| @@ 1475-1485 (lines=11) @@ | ||
| 1472 | * @return static |
|
| 1473 | * <p>(Immutable)</p> |
|
| 1474 | */ |
|
| 1475 | public function each(\Closure $closure): self |
|
| 1476 | { |
|
| 1477 | // init |
|
| 1478 | $array = []; |
|
| 1479 | ||
| 1480 | foreach ($this->getGenerator() as $key => $value) { |
|
| 1481 | $array[$key] = $closure($value, $key); |
|
| 1482 | } |
|
| 1483 | ||
| 1484 | return static::create( |
|
| 1485 | $array, |
|
| 1486 | $this->iteratorClass, |
|
| 1487 | false |
|
| 1488 | ); |
|
| @@ 3583-3594 (lines=12) @@ | ||
| 3580 | * @return static |
|
| 3581 | * <p>(Immutable)</p> |
|
| 3582 | */ |
|
| 3583 | public function reject(\Closure $closure): self |
|
| 3584 | { |
|
| 3585 | // init |
|
| 3586 | $filtered = []; |
|
| 3587 | ||
| 3588 | foreach ($this->getGenerator() as $key => $value) { |
|
| 3589 | if (!$closure($value, $key)) { |
|
| 3590 | $filtered[$key] = $value; |
|
| 3591 | } |
|
| 3592 | } |
|
| 3593 | ||
| 3594 | return static::create( |
|
| 3595 | $filtered, |
|
| 3596 | $this->iteratorClass, |
|
| 3597 | false |
|