| @@ 1425-1435 (lines=11) @@ | ||
| 1422 | * @return static |
|
| 1423 | * <p>(Immutable)</p> |
|
| 1424 | */ |
|
| 1425 | public function each(\Closure $closure) |
|
| 1426 | { |
|
| 1427 | // init |
|
| 1428 | $array = []; |
|
| 1429 | ||
| 1430 | foreach ($this->getGenerator() as $key => $value) { |
|
| 1431 | $array[$key] = $closure($value, $key); |
|
| 1432 | } |
|
| 1433 | ||
| 1434 | return static::create($array, $this->iteratorClass, false); |
|
| 1435 | } |
|
| 1436 | ||
| 1437 | /** |
|
| 1438 | * Check if a value is in the current array using a closure. |
|
| @@ 3258-3269 (lines=12) @@ | ||
| 3255 | * @return static |
|
| 3256 | * <p>(Immutable)</p> |
|
| 3257 | */ |
|
| 3258 | public function reject(\Closure $closure) |
|
| 3259 | { |
|
| 3260 | $filtered = []; |
|
| 3261 | ||
| 3262 | foreach ($this->getGenerator() as $key => $value) { |
|
| 3263 | if (!$closure($value, $key)) { |
|
| 3264 | $filtered[$key] = $value; |
|
| 3265 | } |
|
| 3266 | } |
|
| 3267 | ||
| 3268 | return static::create($filtered, $this->iteratorClass, false); |
|
| 3269 | } |
|
| 3270 | ||
| 3271 | /** |
|
| 3272 | * Remove a value from the current array (optional using dot-notation). |
|