| @@ 1322-1332 (lines=11) @@ | ||
| 1319 | * @return static |
|
| 1320 | * <p>(Immutable)</p> |
|
| 1321 | */ |
|
| 1322 | public function each(\Closure $closure): self |
|
| 1323 | { |
|
| 1324 | // init |
|
| 1325 | $array = []; |
|
| 1326 | ||
| 1327 | foreach ($this->getGenerator() as $key => $value) { |
|
| 1328 | $array[$key] = $closure($value, $key); |
|
| 1329 | } |
|
| 1330 | ||
| 1331 | return static::create($array, $this->iteratorClass, false); |
|
| 1332 | } |
|
| 1333 | ||
| 1334 | /** |
|
| 1335 | * Check if a value is in the current array using a closure. |
|
| @@ 2852-2863 (lines=12) @@ | ||
| 2849 | * @return static |
|
| 2850 | * <p>(Immutable)</p> |
|
| 2851 | */ |
|
| 2852 | public function reject(\Closure $closure): self |
|
| 2853 | { |
|
| 2854 | $filtered = []; |
|
| 2855 | ||
| 2856 | foreach ($this->getGenerator() as $key => $value) { |
|
| 2857 | if (!$closure($value, $key)) { |
|
| 2858 | $filtered[$key] = $value; |
|
| 2859 | } |
|
| 2860 | } |
|
| 2861 | ||
| 2862 | return static::create($filtered, $this->iteratorClass, false); |
|
| 2863 | } |
|
| 2864 | ||
| 2865 | /** |
|
| 2866 | * Remove a value from the current array (optional using dot-notation). |
|