| Conditions | 10 |
| Paths | 6 |
| Total Lines | 31 |
| Code Lines | 21 |
| 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 |
||
| 69 | protected function getParsedOutput($data) |
||
| 70 | { |
||
| 71 | $output = []; |
||
| 72 | foreach ($data as $className => $classInfo) { |
||
| 73 | foreach ($classInfo as $property => $values) { |
||
| 74 | $row = [$className, $property]; |
||
| 75 | if (is_array($values)) { |
||
| 76 | foreach ($values as $key => $value) { |
||
| 77 | $row[] = is_numeric($key) ? '' : $key; |
||
| 78 | $row[] = is_array($value) ? json_encode($value, JSON_PRETTY_PRINT) : $value; |
||
| 79 | if (array_filter($row) != []) { |
||
| 80 | $output[] = $row; |
||
| 81 | } |
||
| 82 | // We need the class and property data for second level values if we're filtering. |
||
| 83 | if ($this->filter !== null) { |
||
| 84 | $row = [$className, $property]; |
||
| 85 | } else { |
||
| 86 | $row = ['', '']; |
||
| 87 | } |
||
| 88 | } |
||
| 89 | } else { |
||
| 90 | $row[] = ''; |
||
| 91 | $row[] = $values; |
||
| 92 | } |
||
| 93 | if (array_filter($row) != []) { |
||
| 94 | $output[] = $row; |
||
| 95 | } |
||
| 96 | } |
||
| 97 | } |
||
| 98 | return $output; |
||
| 99 | } |
||
| 100 | |||
| 121 |