| @@ 1435-1445 (lines=11) @@ | ||
| 1432 | * @return static |
|
| 1433 | * <p>(Immutable)</p> |
|
| 1434 | */ |
|
| 1435 | public function each(\Closure $closure): self |
|
| 1436 | { |
|
| 1437 | // init |
|
| 1438 | $array = []; |
|
| 1439 | ||
| 1440 | foreach ($this->getGenerator() as $key => $value) { |
|
| 1441 | $array[$key] = $closure($value, $key); |
|
| 1442 | } |
|
| 1443 | ||
| 1444 | return static::create( |
|
| 1445 | $array, |
|
| 1446 | $this->iteratorClass, |
|
| 1447 | false |
|
| 1448 | ); |
|
| @@ 3241-3252 (lines=12) @@ | ||
| 3238 | * @return static |
|
| 3239 | * <p>(Immutable)</p> |
|
| 3240 | */ |
|
| 3241 | public function reject(\Closure $closure): self |
|
| 3242 | { |
|
| 3243 | // init |
|
| 3244 | $filtered = []; |
|
| 3245 | ||
| 3246 | foreach ($this->getGenerator() as $key => $value) { |
|
| 3247 | if (!$closure($value, $key)) { |
|
| 3248 | $filtered[$key] = $value; |
|
| 3249 | } |
|
| 3250 | } |
|
| 3251 | ||
| 3252 | return static::create( |
|
| 3253 | $filtered, |
|
| 3254 | $this->iteratorClass, |
|
| 3255 | false |
|