| Conditions | 14 | 
| Paths | 30 | 
| Total Lines | 87 | 
| Code Lines | 73 | 
| 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 | ||
| 225 |     public function getFileIconCollection($iconSet) { | ||
| 226 | |||
| 227 | $fileIcons = []; | ||
| 228 | |||
| 229 | //get all allowed mime types | ||
| 230 | $helper = \XoopsModules\Wgfilemanager\Helper::getInstance(); | ||
| 231 |         $mimetypeHandler   = $helper->getHandler('Mimetype'); | ||
| 232 | $allowedExtensions = $mimetypeHandler->getExtensionArray(); | ||
| 233 | |||
| 234 | $folderPath = ''; | ||
| 235 | $folderUrl = ''; | ||
| 236 | $fileTrailing = ''; | ||
| 237 | $fileDefault = ''; | ||
| 238 | $fileIcons['type'] = ''; | ||
| 239 | |||
| 240 |         switch ($iconSet) { | ||
| 241 | case 'classic': | ||
| 242 | $folderPath = \WGFILEMANAGER_ICONS_PATH . '\fileicons\file-icon-vectors-master\dist\icons\classic' . '/'; | ||
| 243 | $folderUrl = \WGFILEMANAGER_ICONS_URL . '\fileicons\file-icon-vectors-master\dist\icons\classic' . '/'; | ||
| 244 | $fileTrailing = '.svg'; | ||
| 245 | $fileDefault = 'default.svg'; | ||
| 246 | $fileIcons['type'] = 'svg'; | ||
| 247 | break; | ||
| 248 | case 'high-contrast': | ||
| 249 | $folderPath = \WGFILEMANAGER_ICONS_PATH . '\fileicons\file-icon-vectors-master\dist\icons\high-contrast' . '/'; | ||
| 250 | $folderUrl = \WGFILEMANAGER_ICONS_URL . '\fileicons\file-icon-vectors-master\dist\icons\high-contrast' . '/'; | ||
| 251 | $fileTrailing = '.svg'; | ||
| 252 | $fileDefault = 'default.svg'; | ||
| 253 | $fileIcons['type'] = 'svg'; | ||
| 254 | break; | ||
| 255 | case 'square-o': | ||
| 256 | $folderPath = \WGFILEMANAGER_ICONS_PATH . '\fileicons\file-icon-vectors-master\dist\icons\square-o' . '/'; | ||
| 257 | $folderUrl = \WGFILEMANAGER_ICONS_URL . '\fileicons\file-icon-vectors-master\dist\icons\square-o' . '/'; | ||
| 258 | $fileTrailing = '.svg'; | ||
| 259 | $fileDefault = 'default.svg'; | ||
| 260 | $fileIcons['type'] = 'svg'; | ||
| 261 | break; | ||
| 262 | case 'vivid': | ||
| 263 | $folderPath = \WGFILEMANAGER_ICONS_PATH . '\fileicons\file-icon-vectors-master\dist\icons\vivid' . '/'; | ||
| 264 | $folderUrl = \WGFILEMANAGER_ICONS_URL . '\fileicons\file-icon-vectors-master\dist\icons\vivid' . '/'; | ||
| 265 | $fileTrailing = '.svg'; | ||
| 266 | $fileDefault = 'default.svg'; | ||
| 267 | $fileIcons['type'] = 'svg'; | ||
| 268 | break; | ||
| 269 | case 'teambox': | ||
| 270 | $folderPath = \WGFILEMANAGER_ICONS_PATH . '\fileicons\free-file-icons-master\512px' . '/'; | ||
| 271 | $folderUrl = \WGFILEMANAGER_ICONS_URL . '\fileicons\free-file-icons-master\512px' . '/'; | ||
| 272 | $fileTrailing = '.png'; | ||
| 273 | $fileDefault = '_blank.png'; | ||
| 274 | $fileIcons['type'] = 'png'; | ||
| 275 | break; | ||
| 276 | case 'eagerterrier': | ||
| 277 | $folderPath = \WGFILEMANAGER_ICONS_PATH . '\fileicons\mimetypes-link-icons-master\images' . '/'; | ||
| 278 | $folderUrl = \WGFILEMANAGER_ICONS_URL . '\fileicons\mimetypes-link-icons-master\images' . '/'; | ||
| 279 | $fileTrailing = '-icon-128x128.png'; | ||
| 280 | $fileDefault = 'default-128x128.png'; | ||
| 281 | $fileIcons['type'] = 'png'; | ||
| 282 | break; | ||
| 283 | case 'none': | ||
| 284 | break; | ||
| 285 | case '': | ||
| 286 | default: | ||
| 287 |                 throw new \Exception('Invalid iconset!'); | ||
| 288 | } | ||
| 289 | |||
| 290 |         if ($iconSet == 'none') { | ||
| 291 |             foreach ($allowedExtensions as $allowedExt) { | ||
| 292 | $fileIcons['files'][$allowedExt['extension']]['src'] = ''; | ||
| 293 | $fileIcons['files'][$allowedExt['extension']]['category'] = $allowedExt['category']; | ||
| 294 | } | ||
| 295 |         } else { | ||
| 296 |             if (file_exists($folderPath)) { | ||
| 297 |                 foreach ($allowedExtensions as $allowedExt) { | ||
| 298 | $filePath = $folderPath . $allowedExt['extension'] . $fileTrailing; | ||
| 299 |                     if (file_exists($filePath)) { | ||
| 300 | $fileIcons['files'][$allowedExt['extension']]['src'] = $folderUrl . $allowedExt['extension'] . $fileTrailing; | ||
| 301 | $fileIcons['files'][$allowedExt['extension']]['category'] = $allowedExt['category']; | ||
| 302 |                     } else { | ||
| 303 | $fileIcons['default'] = $fileDefault; | ||
| 304 | } | ||
| 305 | } | ||
| 306 |             } else { | ||
| 307 |                 throw new \Exception('Folder does not exist!'); | ||
| 308 | } | ||
| 309 | } | ||
| 310 | |||
| 311 | return $fileIcons; | ||
| 312 | |||
| 338 |