Conditions | 10 |
Paths | 10 |
Total Lines | 38 |
Code Lines | 17 |
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 |
||
108 | public static function makeBoot($loader = false) |
||
109 | { |
||
110 | $controllers = [root . '/Apps/Controller/' . env_name]; |
||
111 | // get custom apps directories from composer autoloader maps |
||
112 | if ($loader !== false) { |
||
113 | $sources = $loader->getPrefixes(); |
||
114 | // is there any custom paths for apps binding? |
||
115 | if (Obj::isArray($sources) && isset($sources['Apps\\'])) { |
||
116 | // each every one add a new path to controllers map |
||
117 | $controllers = []; |
||
118 | foreach ($sources['Apps\\'] as $path) { |
||
119 | $controllers[] = $path . '/Apps/Controller/' . env_name; |
||
120 | } |
||
121 | } |
||
122 | } |
||
123 | |||
124 | // each every path try to run boot method in ever controller |
||
125 | foreach ($controllers as $path) { |
||
126 | // check if directory exists |
||
127 | if (!Directory::exist($path)) { |
||
128 | continue; |
||
129 | } |
||
130 | $list = File::listFiles($path, ['.php'], true); |
||
131 | // foreach all files in list |
||
132 | foreach ($list as $file) { |
||
133 | // define full class name with namespace |
||
134 | $class = 'Apps\Controller\\' . env_name . '\\' . Str::cleanExtension($file); |
||
135 | // check if class exists (must be loaded over autoloader) |
||
136 | if (class_exists($class)) { |
||
137 | // check if static method boot is exists |
||
138 | if (method_exists($class, 'boot')) { |
||
139 | // call to boot method |
||
140 | call_user_func([$class, 'boot']); |
||
141 | } |
||
142 | } |
||
143 | } |
||
144 | } |
||
145 | } |
||
146 | |||
157 | } |
This check marks private properties in classes that are never used. Those properties can be removed.