Conditions | 20 |
Paths | 21 |
Total Lines | 63 |
Code Lines | 42 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
144 | break; |
||
145 | case 'level_name': |
||
146 | break; |
||
147 | |||
148 | case 'extra': |
||
149 | $normalizedArray = $this->normalize($value); |
||
150 | |||
151 | if ($this->extractExtras) { |
||
152 | $normalized = array_merge($normalizedArray, $normalized); |
||
|
|||
153 | } else { |
||
154 | $normalized['Extra'] = $normalizedArray; |
||
155 | } |
||
156 | break; |
||
157 | |||
158 | case 'context': |
||
159 | $exception = $this->extractException($value); |
||
160 | $normalizedArray = $this->normalize($value); |
||
161 | |||
162 | if ($this->extractContext) { |
||
163 | $normalized = array_merge($normalizedArray, $normalized); |
||
164 | } else { |
||
165 | $normalized['Context'] = $normalizedArray; |
||
166 | } |
||
167 | |||
168 | if ($exception !== null) { |
||
169 | if (($exception instanceof Exception || $exception instanceof Throwable)) { |
||
170 | $exception = $this->normalizeException($exception); |
||
171 | } |
||
172 | |||
173 | $normalized['@x'] = $exception; |
||
174 | } |
||
175 | break; |
||
176 | |||
177 | default: |
||
178 | $normalized[is_int($key) ? $key : SeqCompactJsonFormatter::ConvertSnakeCaseToPascalCase($key)] = $this->normalize($value); |
||
179 | break; |
||
180 | } |
||
181 | } |
||
182 | |||
183 | return $normalized; |
||
184 | } |
||
185 | |||
186 | if ($data instanceof Exception || $data instanceof Throwable) { |
||
187 | return $this->normalizeException($data); |
||
188 | } |
||
189 | |||
190 | return $data; |
||
191 | } |
||
192 | } |