| @@ 717-726 (lines=10) @@ | ||
| 714 | * |
|
| 715 | * @return static <p>(Immutable)</p> |
|
| 716 | */ |
|
| 717 | public function at(\Closure $closure) |
|
| 718 | { |
|
| 719 | $array = $this->array; |
|
| 720 | ||
| 721 | foreach ($array as $key => $value) { |
|
| 722 | $closure($value, $key); |
|
| 723 | } |
|
| 724 | ||
| 725 | return static::create($array); |
|
| 726 | } |
|
| 727 | ||
| 728 | /** |
|
| 729 | * Returns the average value of the current array. |
|
| @@ 1278-1287 (lines=10) @@ | ||
| 1275 | * |
|
| 1276 | * @return static <p>(Immutable)</p> |
|
| 1277 | */ |
|
| 1278 | public function each(\Closure $closure) |
|
| 1279 | { |
|
| 1280 | $array = $this->array; |
|
| 1281 | ||
| 1282 | foreach ($array as $key => $value) { |
|
| 1283 | $array[$key] = $closure($value, $key); |
|
| 1284 | } |
|
| 1285 | ||
| 1286 | return static::create($array); |
|
| 1287 | } |
|
| 1288 | ||
| 1289 | /** |
|
| 1290 | * Check if a value is in the current array using a closure. |
|
| @@ 1530-1539 (lines=10) @@ | ||
| 1527 | * |
|
| 1528 | * @return mixed|false <p>Return false if we did not find the value.</p> |
|
| 1529 | */ |
|
| 1530 | public function find(\Closure $closure) |
|
| 1531 | { |
|
| 1532 | foreach ($this->array as $key => $value) { |
|
| 1533 | if ($closure($value, $key)) { |
|
| 1534 | return $value; |
|
| 1535 | } |
|
| 1536 | } |
|
| 1537 | ||
| 1538 | return false; |
|
| 1539 | } |
|
| 1540 | ||
| 1541 | /** |
|
| 1542 | * find by ... |
|
| @@ 3016-3027 (lines=12) @@ | ||
| 3013 | * |
|
| 3014 | * @return static <p>(Immutable)</p> |
|
| 3015 | */ |
|
| 3016 | public function reject(\Closure $closure) |
|
| 3017 | { |
|
| 3018 | $filtered = []; |
|
| 3019 | ||
| 3020 | foreach ($this->array as $key => $value) { |
|
| 3021 | if (!$closure($value, $key)) { |
|
| 3022 | $filtered[$key] = $value; |
|
| 3023 | } |
|
| 3024 | } |
|
| 3025 | ||
| 3026 | return static::create($filtered); |
|
| 3027 | } |
|
| 3028 | ||
| 3029 | /** |
|
| 3030 | * Remove a value from the current array (optional using dot-notation). |
|