| Conditions | 10 |
| Paths | 12 |
| Total Lines | 26 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | 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 |
||
| 43 | protected static function export() |
||
| 44 | { |
||
| 45 | $data = self::$exportDataAsDisplayed ? |
||
| 46 | self::$data : |
||
| 47 | self::select(self::$t['q']); |
||
| 48 | $outColumns = $outHeader = []; |
||
| 49 | foreach (self::$cols as $c) { |
||
| 50 | if (isset($c[2]['sort']) && $c[2]['sort'] === false) { |
||
| 51 | continue; |
||
| 52 | } |
||
| 53 | $outColumns[] = $c[1]; |
||
| 54 | $outHeader[] = $c[0]; |
||
| 55 | } |
||
| 56 | $eData = [$outHeader]; |
||
| 57 | if (count($data) > 0) { |
||
| 58 | foreach ($data as $row) { |
||
| 59 | $rowData = []; |
||
| 60 | foreach ($row as $dbName => $value) { |
||
| 61 | if (in_array($dbName, $outColumns)) { |
||
| 62 | $rowData[] = is_array($value) ? $value[0] : $value; |
||
| 63 | } |
||
| 64 | } |
||
| 65 | $eData[] = $rowData; |
||
| 66 | } |
||
| 67 | } |
||
| 68 | self::exportFile($eData); |
||
| 69 | } |
||
| 107 |