Conditions | 9 |
Paths | 2 |
Total Lines | 53 |
Code Lines | 30 |
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 |
||
89 | public function listOfAvailableExportFormat($db, $maxfilenamelength = 0) |
||
90 | { |
||
91 | global $langs; |
||
92 | |||
93 | dol_syslog(get_class($this) . "::listOfAvailableExportFormat"); |
||
94 | |||
95 | $dir = DOL_DOCUMENT_ROOT . "/core/modules/export/"; |
||
96 | $handle = opendir($dir); |
||
97 | |||
98 | // Recherche des fichiers drivers exports disponibles |
||
99 | $i = 0; |
||
100 | if (is_resource($handle)) { |
||
101 | while (($file = readdir($handle)) !== false) { |
||
102 | $reg = array(); |
||
103 | if (preg_match("/^export_(.*)\.modules\.php$/i", $file, $reg)) { |
||
104 | $moduleid = $reg[1]; |
||
105 | if ($moduleid == 'csv') { |
||
106 | continue; // This may happen if on old file export_csv.modules.php was not correctly deleted |
||
107 | } |
||
108 | |||
109 | // Loading Class |
||
110 | $file = $dir . "export_" . $moduleid . ".modules.php"; |
||
111 | $classname = "Export" . ucfirst($moduleid); |
||
112 | |||
113 | require_once $file; |
||
114 | if (class_exists($classname)) { |
||
115 | $module = new $classname($db); |
||
116 | // var_dump($classname); |
||
117 | |||
118 | // Picto |
||
119 | $this->picto[$module->id] = $module->picto; |
||
120 | // Driver properties |
||
121 | $this->driverlabel[$module->id] = $module->getDriverLabel() . (empty($module->disabled) ? '' : ' __(Disabled)__'); // '__(Disabled)__' is a key |
||
122 | if (method_exists($module, 'getDriverLabelBis')) { |
||
123 | if ($module->getDriverLabelBis()) { |
||
124 | $this->driverlabel[$module->id] .= ' <span class="opacitymedium">(' . $module->getDriverLabelBis() . ')</span>'; |
||
125 | } |
||
126 | } |
||
127 | $this->driverdesc[$module->id] = $module->getDriverDesc(); |
||
128 | $this->driverversion[$module->id] = $module->getDriverVersion(); |
||
129 | // If use an external lib |
||
130 | $this->liblabel[$module->id] = $module->getLibLabel(); |
||
131 | $this->libversion[$module->id] = $module->getLibVersion(); |
||
132 | } |
||
133 | $i++; |
||
134 | } |
||
135 | } |
||
136 | closedir($handle); |
||
137 | } |
||
138 | |||
139 | asort($this->driverlabel); |
||
140 | |||
141 | return $this->driverlabel; |
||
142 | } |
||
211 |