Conditions | 2 |
Paths | 2 |
Total Lines | 51 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
101 | private function getMenuByPeople(People $userPeople, People $myCompany) |
||
102 | { |
||
103 | |||
104 | $return = []; |
||
105 | $connection = $this->manager->getConnection(); |
||
106 | |||
107 | // build query |
||
108 | |||
109 | $sql = 'SELECT menu.*, |
||
110 | category.name AS category_label, |
||
111 | category.color AS category_color, |
||
112 | routes.route AS route, |
||
113 | category.icon AS category_icon FROM menu |
||
114 | INNER JOIN category ON category.id = menu.category_id |
||
115 | INNER JOIN menu_role ON menu.id = menu_role.menu_id |
||
116 | INNER JOIN people_role ON people_role.role_id = menu_role.role_id |
||
117 | INNER JOIN routes ON routes.id = menu.route_id |
||
118 | WHERE people_role.company_id=:myCompany AND people_role.people_id=:userPeople |
||
119 | GROUP BY menu.id |
||
120 | '; |
||
121 | |||
122 | |||
123 | $params = []; |
||
124 | |||
125 | $params['myCompany'] = $myCompany->getId(); |
||
126 | $params['userPeople'] = $userPeople->getId(); |
||
127 | // execute query |
||
128 | |||
129 | $statement = $connection->prepare($sql); |
||
130 | $statement->execute($params); |
||
131 | |||
132 | $result = $statement->fetchAll(); |
||
133 | |||
134 | foreach ($result as $menu) { |
||
135 | |||
136 | $return['modules'][$menu['category_id']]['id'] = $menu['category_id']; |
||
137 | $return['modules'][$menu['category_id']]['label'] = $menu['category_label']; |
||
138 | $return['modules'][$menu['category_id']]['color'] = $menu['category_color']; |
||
139 | $return['modules'][$menu['category_id']]['icon'] = $menu['category_icon']; |
||
140 | $return['modules'][$menu['category_id']]['menus'][] = [ |
||
141 | 'id' => $menu['id'], |
||
142 | 'label' => $menu['menu'], |
||
143 | 'icon' => $menu['icon'], |
||
144 | 'color' => $menu['color'], |
||
145 | 'route' => $menu['route'], |
||
146 | ]; |
||
147 | } |
||
148 | |||
149 | |||
150 | |||
151 | return $return; |
||
152 | } |
||
154 |
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