| Conditions | 19 |
| Paths | 65 |
| Total Lines | 38 |
| Code Lines | 25 |
| 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 |
||
| 13 | public function loadLib($libName, $options = []) { |
||
| 14 | $className = 'Inji\Libs\\' . ucfirst($libName); |
||
| 15 | if (class_exists($className)) { |
||
| 16 | if (!empty($className::$composerPacks)) { |
||
|
|
|||
| 17 | foreach ($className::$composerPacks as $packageName => $version) { |
||
| 18 | ComposerCmd::requirePackage($packageName, $version); |
||
| 19 | } |
||
| 20 | } |
||
| 21 | if (!empty($className::$bowerPacks)) { |
||
| 22 | foreach ($className::$bowerPacks as $packageName => $version) { |
||
| 23 | BowerCmd::requirePackage($packageName, $version); |
||
| 24 | } |
||
| 25 | } |
||
| 26 | if (!empty($className::$requiredLibs)) { |
||
| 27 | foreach ($className::$requiredLibs as $rLib) { |
||
| 28 | $this->loadLib($rLib); |
||
| 29 | } |
||
| 30 | } |
||
| 31 | if (!empty($className::$files['css']) && (!isset($options['loadCss']) || $options['loadCss'])) { |
||
| 32 | foreach ($className::$files['css'] as $file) { |
||
| 33 | if (strpos($file, '/') === 0 || strpos($file, 'http') === 0) { |
||
| 34 | App::$cur->view->customAsset('css', $file, $libName); |
||
| 35 | } else { |
||
| 36 | App::$cur->view->customAsset('css', '/static/libs/vendor/' . ucfirst($libName) . '/' . $file, $libName); |
||
| 37 | } |
||
| 38 | } |
||
| 39 | } |
||
| 40 | if (!empty($className::$files['js'])) { |
||
| 41 | foreach ($className::$files['js'] as $file) { |
||
| 42 | if (strpos($file, '/') === 0 || strpos($file, 'http') === 0) { |
||
| 43 | App::$cur->view->customAsset('js', $file, $libName); |
||
| 44 | } else { |
||
| 45 | App::$cur->view->customAsset('js', '/static/libs/vendor/' . ucfirst($libName) . '/' . $file, $libName); |
||
| 46 | } |
||
| 47 | } |
||
| 48 | } |
||
| 49 | if (!empty($className::$files['bower'])) { |
||
| 50 | $this->bowerFiles($libName, $className::$files['bower'], $options); |
||
| 51 | } |
||
| 100 | } |