Conditions | 11 |
Paths | 20 |
Total Lines | 37 |
Code Lines | 18 |
Lines | 9 |
Ratio | 24.32 % |
Changes | 2 | ||
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 |
||
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 | |||
109 | if ( ! is_array($data)) { |
||
110 | $data = []; |
||
111 | } |
||
112 | } |
||
113 | |||
114 | if (count($keys) === 0) { |
||
115 | foreach ($data as $itemKey => $itemValue) { |
||
116 | $values[$itemKey] = $itemValue; |
||
117 | } |
||
118 | } |
||
119 | |||
120 | if (count($keys) > 0) { |
||
121 | foreach ($data as $itemKey => $itemValue) { |
||
122 | // since there are still selector keys left and the next |
||
123 | // item is not an array, it is safe to skip it |
||
124 | if ( ! is_array($itemValue)) { |
||
125 | continue; |
||
126 | } |
||
127 | |||
128 | $nestedValues = $this->getValues($itemValue, $keys); |
||
129 | |||
130 | foreach ($nestedValues as $nestedKey => $nestedValue) { |
||
131 | $values[$this->buildKey($itemKey, $nestedKey)] = $nestedValue; |
||
132 | } |
||
133 | } |
||
134 | } |
||
135 | |||
136 | return $values; |
||
137 | } |
||
138 | |||
190 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.