| @@ 685-694 (lines=10) @@ | ||
| 682 | * |
|
| 683 | * @return static <p>(Immutable)</p> |
|
| 684 | */ |
|
| 685 | public function at(\Closure $closure) |
|
| 686 | { |
|
| 687 | $array = $this->array; |
|
| 688 | ||
| 689 | foreach ($array as $key => $value) { |
|
| 690 | $closure($value, $key); |
|
| 691 | } |
|
| 692 | ||
| 693 | return static::create($array); |
|
| 694 | } |
|
| 695 | ||
| 696 | /** |
|
| 697 | * Returns the average value of the current array. |
|
| @@ 1246-1255 (lines=10) @@ | ||
| 1243 | * |
|
| 1244 | * @return static <p>(Immutable)</p> |
|
| 1245 | */ |
|
| 1246 | public function each(\Closure $closure) |
|
| 1247 | { |
|
| 1248 | $array = $this->array; |
|
| 1249 | ||
| 1250 | foreach ($array as $key => $value) { |
|
| 1251 | $array[$key] = $closure($value, $key); |
|
| 1252 | } |
|
| 1253 | ||
| 1254 | return static::create($array); |
|
| 1255 | } |
|
| 1256 | ||
| 1257 | /** |
|
| 1258 | * Check if a value is in the current array using a closure. |
|
| @@ 1498-1507 (lines=10) @@ | ||
| 1495 | * |
|
| 1496 | * @return mixed|false <p>Return false if we did not find the value.</p> |
|
| 1497 | */ |
|
| 1498 | public function find(\Closure $closure) |
|
| 1499 | { |
|
| 1500 | foreach ($this->array as $key => $value) { |
|
| 1501 | if ($closure($value, $key)) { |
|
| 1502 | return $value; |
|
| 1503 | } |
|
| 1504 | } |
|
| 1505 | ||
| 1506 | return false; |
|
| 1507 | } |
|
| 1508 | ||
| 1509 | /** |
|
| 1510 | * find by ... |
|
| @@ 2942-2953 (lines=12) @@ | ||
| 2939 | * |
|
| 2940 | * @return static <p>(Immutable)</p> |
|
| 2941 | */ |
|
| 2942 | public function reject(\Closure $closure) |
|
| 2943 | { |
|
| 2944 | $filtered = []; |
|
| 2945 | ||
| 2946 | foreach ($this->array as $key => $value) { |
|
| 2947 | if (!$closure($value, $key)) { |
|
| 2948 | $filtered[$key] = $value; |
|
| 2949 | } |
|
| 2950 | } |
|
| 2951 | ||
| 2952 | return static::create($filtered); |
|
| 2953 | } |
|
| 2954 | ||
| 2955 | /** |
|
| 2956 | * Remove a value from the current array (optional using dot-notation). |
|