| Conditions | 12 |
| Paths | 6 |
| Total Lines | 39 |
| Code Lines | 27 |
| 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 |
||
| 70 | protected function getParsedOutput($data) |
||
| 71 | { |
||
| 72 | $output = []; |
||
| 73 | foreach ($data as $className => $classInfo) { |
||
| 74 | foreach ($classInfo as $property => $values) { |
||
| 75 | $row = [$className, $property]; |
||
| 76 | if (is_array($values) || is_object($values)) { |
||
| 77 | foreach ($values as $key => $value) { |
||
| 78 | $row[] = is_numeric($key) ? '' : $key; |
||
| 79 | if (is_array($value)) { |
||
| 80 | $value = Convert::raw2json($value, JSON_PRETTY_PRINT); |
||
| 81 | } elseif (is_object($value)) { |
||
| 82 | $value = get_class($value); |
||
| 83 | } else { |
||
| 84 | $value = (string) $value; |
||
| 85 | } |
||
| 86 | $row[] = $value; |
||
| 87 | if (array_filter($row) != []) { |
||
| 88 | $output[] = $row; |
||
| 89 | } |
||
| 90 | // We need the class and property data for second level values if we're filtering. |
||
| 91 | if ($this->filter !== null) { |
||
| 92 | $row = [$className, $property]; |
||
| 93 | } else { |
||
| 94 | $row = ['', '']; |
||
| 95 | } |
||
| 96 | } |
||
| 97 | } else { |
||
| 98 | $row[] = ''; |
||
| 99 | $row[] = $values; |
||
| 100 | } |
||
| 101 | |||
| 102 | if (array_filter($row) != []) { |
||
| 103 | $output[] = $row; |
||
| 104 | } |
||
| 105 | } |
||
| 106 | } |
||
| 107 | return $output; |
||
| 108 | } |
||
| 109 | |||
| 130 |