| @@ 1364-1374 (lines=11) @@ | ||
| 1361 | * @return static |
|
| 1362 | * <p>(Immutable)</p> |
|
| 1363 | */ |
|
| 1364 | public function each(\Closure $closure): self |
|
| 1365 | { |
|
| 1366 | // init |
|
| 1367 | $array = []; |
|
| 1368 | ||
| 1369 | foreach ($this->getGenerator() as $key => $value) { |
|
| 1370 | $array[$key] = $closure($value, $key); |
|
| 1371 | } |
|
| 1372 | ||
| 1373 | return static::create($array, $this->iteratorClass, false); |
|
| 1374 | } |
|
| 1375 | ||
| 1376 | /** |
|
| 1377 | * Check if a value is in the current array using a closure. |
|
| @@ 2949-2960 (lines=12) @@ | ||
| 2946 | * @return static |
|
| 2947 | * <p>(Immutable)</p> |
|
| 2948 | */ |
|
| 2949 | public function reject(\Closure $closure): self |
|
| 2950 | { |
|
| 2951 | // init |
|
| 2952 | $filtered = []; |
|
| 2953 | ||
| 2954 | foreach ($this->getGenerator() as $key => $value) { |
|
| 2955 | if (!$closure($value, $key)) { |
|
| 2956 | $filtered[$key] = $value; |
|
| 2957 | } |
|
| 2958 | } |
|
| 2959 | ||
| 2960 | return static::create($filtered, $this->iteratorClass, false); |
|
| 2961 | } |
|
| 2962 | ||
| 2963 | /** |
|