| Conditions | 12 |
| Paths | 12 |
| Total Lines | 29 |
| Code Lines | 16 |
| 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 |
||
| 98 | public function compileBootableClasses(): void |
||
| 99 | { |
||
| 100 | // list app root's |
||
| 101 | foreach ($this->appRoots as $app) { |
||
| 102 | $app .= '/Apps/Controller/' . env_name; |
||
| 103 | $files = File::listFiles($app, ['.php'], true); |
||
| 104 | foreach ($files as $file) { |
||
| 105 | // define full class name with namespace |
||
| 106 | $class = 'Apps\Controller\\' . env_name . '\\' . Str::cleanExtension($file); |
||
| 107 | // check if class exists (must be loaded over autoloader), boot method exist and this is controller instanceof |
||
| 108 | if (class_exists($class) && method_exists($class, 'boot') && is_a($class, 'Ffcms\Core\Arch\Controller', true)) { |
||
| 109 | $this->objects[] = $class; |
||
| 110 | } |
||
| 111 | } |
||
| 112 | } |
||
| 113 | |||
| 114 | // list widget root's |
||
| 115 | foreach ($this->widgetRoots as $widget) { |
||
| 116 | $widget .= '/Widgets/' . env_name; |
||
| 117 | // widgets are packed in directory, classname should be the same with root directory name |
||
| 118 | $dirs = Directory::scan($widget, GLOB_ONLYDIR, true); |
||
| 119 | if (!Any::isArray($dirs)) { |
||
| 120 | continue; |
||
| 121 | } |
||
| 122 | |||
| 123 | foreach ($dirs as $instance) { |
||
| 124 | $class = 'Widgets\\' . env_name . '\\' . $instance . '\\' . $instance; |
||
| 125 | if (class_exists($class) && method_exists($class, 'boot') && is_a($class, 'Ffcms\Core\Arch\Widget', true)) { |
||
| 126 | $this->objects[] = $class; |
||
| 127 | } |
||
| 152 |