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