| @@ 1478-1488 (lines=11) @@ | ||
| 1475 | * @return static |
|
| 1476 | * <p>(Immutable)</p> |
|
| 1477 | */ |
|
| 1478 | public function each(\Closure $closure): self |
|
| 1479 | { |
|
| 1480 | // init |
|
| 1481 | $array = []; |
|
| 1482 | ||
| 1483 | foreach ($this->getGenerator() as $key => $value) { |
|
| 1484 | $array[$key] = $closure($value, $key); |
|
| 1485 | } |
|
| 1486 | ||
| 1487 | return static::create( |
|
| 1488 | $array, |
|
| 1489 | $this->iteratorClass, |
|
| 1490 | false |
|
| 1491 | ); |
|
| @@ 3508-3519 (lines=12) @@ | ||
| 3505 | * @return static |
|
| 3506 | * <p>(Immutable)</p> |
|
| 3507 | */ |
|
| 3508 | public function reject(\Closure $closure): self |
|
| 3509 | { |
|
| 3510 | // init |
|
| 3511 | $filtered = []; |
|
| 3512 | ||
| 3513 | foreach ($this->getGenerator() as $key => $value) { |
|
| 3514 | if (!$closure($value, $key)) { |
|
| 3515 | $filtered[$key] = $value; |
|
| 3516 | } |
|
| 3517 | } |
|
| 3518 | ||
| 3519 | return static::create( |
|
| 3520 | $filtered, |
|
| 3521 | $this->iteratorClass, |
|
| 3522 | false |
|