| @@ 241-250 (lines=10) @@ | ||
| 238 | * |
|
| 239 | * @return Arrayy (Immutable) |
|
| 240 | */ |
|
| 241 | public function at(\Closure $closure) |
|
| 242 | { |
|
| 243 | $array = $this->array; |
|
| 244 | ||
| 245 | foreach ($array as $key => $value) { |
|
| 246 | $closure($value, $key); |
|
| 247 | } |
|
| 248 | ||
| 249 | return static::create($array); |
|
| 250 | } |
|
| 251 | ||
| 252 | /** |
|
| 253 | * Returns the average value of the current array. |
|
| @@ 515-524 (lines=10) @@ | ||
| 512 | * |
|
| 513 | * @return Arrayy (Immutable) |
|
| 514 | */ |
|
| 515 | public function each(\Closure $closure) |
|
| 516 | { |
|
| 517 | $array = $this->array; |
|
| 518 | ||
| 519 | foreach ($array as $key => &$value) { |
|
| 520 | $value = $closure($value, $key); |
|
| 521 | } |
|
| 522 | ||
| 523 | return static::create($array); |
|
| 524 | } |
|
| 525 | ||
| 526 | /** |
|
| 527 | * Check if a value is in the current array using a closure. |
|
| @@ 1727-1738 (lines=12) @@ | ||
| 1724 | * |
|
| 1725 | * @return Arrayy (Immutable) |
|
| 1726 | */ |
|
| 1727 | public function reject(\Closure $closure) |
|
| 1728 | { |
|
| 1729 | $filtered = array(); |
|
| 1730 | ||
| 1731 | foreach ($this->array as $key => $value) { |
|
| 1732 | if (!$closure($value, $key)) { |
|
| 1733 | $filtered[$key] = $value; |
|
| 1734 | } |
|
| 1735 | } |
|
| 1736 | ||
| 1737 | return static::create($filtered); |
|
| 1738 | } |
|
| 1739 | ||
| 1740 | /** |
|
| 1741 | * Remove a value from the current array (optional using dot-notation). |
|