Conditions | 10 |
Paths | 12 |
Total Lines | 33 |
Code Lines | 25 |
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 |
||
44 | protected static function export() |
||
45 | { |
||
46 | $data = self::$exportDataAsDisplayed ? |
||
47 | self::$data : |
||
48 | self::select(self::$t['q']); |
||
49 | $fnReplace = []; |
||
50 | $fnReplace[':app'] = self::config('APP'); |
||
51 | $fnReplace[':items'] = self::$t['items']; |
||
52 | $format = str_replace(':', '.', '%d.%m.%Y %H:%i:%s'); |
||
53 | $timeQuery = 'SELECT DATE_FORMAT(Now(), "' . $format . '") AS `now`;'; |
||
54 | $fnReplace[':datetime'] = self::select($timeQuery); |
||
55 | $outFilename = strtr(self::config('EXPORT_FILE_NAME'), $fnReplace); |
||
|
|||
56 | $outColumns = $outHeader = []; |
||
57 | foreach (self::$cols as $c) { |
||
58 | if (isset($c[2]['sort']) && $c[2]['sort'] === false) { |
||
59 | continue; |
||
60 | } |
||
61 | $outColumns[] = $c[1]; |
||
62 | $outHeader[] = $c[0]; |
||
63 | } |
||
64 | $eData = [$outHeader]; |
||
65 | if (count($data) > 0) { |
||
66 | foreach ($data as $row) { |
||
67 | $rowData = []; |
||
68 | foreach ($row as $dbName => $value) { |
||
69 | if (in_array($dbName, $outColumns)) { |
||
70 | $rowData[] = is_array($value) ? $value[0] : $value; |
||
71 | } |
||
72 | } |
||
73 | $eData[] = $rowData; |
||
74 | } |
||
75 | } |
||
76 | self::export2file($eData, $outFilename); |
||
77 | } |
||
103 |