Conditions | 12 |
Paths | 20 |
Total Lines | 35 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
73 | * @return array |
||
74 | */ |
||
75 | protected function getWildcardKeys($data, array $keys) { |
||
|
|||
76 | $values = []; |
||
77 | |||
78 | View Code Duplication | if ( ! is_array($data) && ! $data instanceof Traversable) { |
|
79 | if ($data instanceof IArrayable) { |
||
80 | $data = $data->toArray(); |
||
81 | } |
||
82 | |||
83 | if ( ! is_array($data)) { |
||
84 | $data = []; |
||
85 | } |
||
86 | } |
||
87 | |||
88 | foreach ($data as $itemKey => $itemValue) { |
||
89 | $values[$itemKey] = $itemKey; |
||
90 | } |
||
91 | |||
92 | return $values; |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * @param mixed $data |
||
97 | * @param array $keys |
||
98 | * |
||
99 | * @return array |
||
100 | */ |
||
101 | protected function getWildcardValues($data, array $keys) { |
||
102 | $values = []; |
||
103 | |||
104 | View Code Duplication | if ( ! is_array($data) && ! $data instanceof Traversable) { |
|
105 | if ($data instanceof IArrayable) { |
||
106 | $data = $data->toArray(); |
||
107 | } |
||
108 | |||
188 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.