| @@ 239-248 (lines=10) @@ | ||
| 236 | * |
|
| 237 | * @return Arrayy (Immutable) |
|
| 238 | */ |
|
| 239 | public function at(\Closure $closure) |
|
| 240 | { |
|
| 241 | $array = $this->array; |
|
| 242 | ||
| 243 | foreach ($array as $key => $value) { |
|
| 244 | $closure($value, $key); |
|
| 245 | } |
|
| 246 | ||
| 247 | return static::create($array); |
|
| 248 | } |
|
| 249 | ||
| 250 | /** |
|
| 251 | * Returns the average value of the current array. |
|
| @@ 513-522 (lines=10) @@ | ||
| 510 | * |
|
| 511 | * @return Arrayy (Immutable) |
|
| 512 | */ |
|
| 513 | public function each(\Closure $closure) |
|
| 514 | { |
|
| 515 | $array = $this->array; |
|
| 516 | ||
| 517 | foreach ($array as $key => &$value) { |
|
| 518 | $value = $closure($value, $key); |
|
| 519 | } |
|
| 520 | ||
| 521 | return static::create($array); |
|
| 522 | } |
|
| 523 | ||
| 524 | /** |
|
| 525 | * Check if a value is in the current array using a closure. |
|
| @@ 1744-1755 (lines=12) @@ | ||
| 1741 | * |
|
| 1742 | * @return Arrayy (Immutable) |
|
| 1743 | */ |
|
| 1744 | public function reject(\Closure $closure) |
|
| 1745 | { |
|
| 1746 | $filtered = array(); |
|
| 1747 | ||
| 1748 | foreach ($this->array as $key => $value) { |
|
| 1749 | if (!$closure($value, $key)) { |
|
| 1750 | $filtered[$key] = $value; |
|
| 1751 | } |
|
| 1752 | } |
|
| 1753 | ||
| 1754 | return static::create($filtered); |
|
| 1755 | } |
|
| 1756 | ||
| 1757 | /** |
|
| 1758 | * Remove a value from the current array (optional using dot-notation). |
|