Conditions | 4 |
Paths | 3 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
41 | public function only($keys) |
||
42 | { |
||
43 | $results = []; |
||
44 | |||
45 | $input = $this->all(); |
||
46 | |||
47 | $placeholder = new stdClass; |
||
48 | |||
49 | foreach (is_array($keys) ? $keys : func_get_args() as $key) { |
||
50 | $value = data_get($input, $key, $placeholder); |
||
51 | |||
52 | if ($value !== $placeholder) { |
||
53 | Arr::set($results, $key, $value); |
||
54 | } |
||
55 | } |
||
56 | |||
57 | return $results; |
||
58 | } |
||
59 | |||
70 |
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: