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