Complex classes like UsersController often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use UsersController, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
11 | class UsersController extends adminController { |
||
12 | |||
13 | public function loginAction() { |
||
14 | if (!Users\User::$cur->user_id) { |
||
15 | $this->view->page(['page' => 'login', 'content' => 'login']); |
||
16 | } else { |
||
17 | $this->view->page(['content' => 'profile']); |
||
18 | } |
||
19 | } |
||
20 | |||
21 | public function loginAsAction($userId) { |
||
25 | } |
||
26 | |||
27 | } |
||
28 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths