| Conditions | 2 |
| Paths | 1 |
| Total Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php namespace Spatie\CollectionMacros\Macros; |
||
| 15 | public function extract() |
||
| 16 | { |
||
| 17 | return function ($keys): Collection { |
||
| 18 | $keys = is_array($keys) ? $keys : func_get_args(); |
||
| 19 | |||
| 20 | return array_reduce($keys, function ($extracted, $key) { |
||
| 21 | return $extracted->push(data_get($this->items, $key)); |
||
|
|
|||
| 22 | }, new static()); |
||
| 23 | }; |
||
| 24 | } |
||
| 25 | } |
||
| 26 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: