Conditions | 2 |
Paths | 2 |
Total Lines | 51 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 5 | ||
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 |
||
102 | private function getMenuByPeople(People $userPeople, People $myCompany) |
||
103 | { |
||
104 | |||
105 | $return = []; |
||
106 | $connection = $this->manager->getConnection(); |
||
107 | |||
108 | // build query |
||
109 | |||
110 | $sql = 'SELECT menu.*, |
||
111 | category.name AS category_label, |
||
112 | category.color AS category_color, |
||
113 | routes.route AS route, |
||
114 | routes.color AS color, |
||
115 | routes.icon AS icon, |
||
116 | routes.module_id AS module, |
||
117 | category.icon AS category_icon FROM menu |
||
118 | INNER JOIN category ON category.id = menu.category_id |
||
119 | INNER JOIN menu_role ON menu.id = menu_role.menu_id |
||
120 | INNER JOIN people_role ON people_role.role_id = menu_role.role_id |
||
121 | INNER JOIN routes ON routes.id = menu.route_id '; |
||
122 | //$sql .= 'WHERE people_role.company_id=:myCompany AND people_role.people_id=:userPeople '; |
||
123 | $sql .= 'GROUP BY menu.id'; |
||
124 | |||
125 | |||
126 | $params = []; |
||
127 | |||
128 | //$params['myCompany'] = $myCompany->getId(); |
||
129 | //$params['userPeople'] = $userPeople->getId(); |
||
130 | // execute query |
||
131 | |||
132 | $result = $connection->executeQuery($sql, $params)->fetchAllAssociative(); |
||
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 | 'module' => '/modules/' . $menu['module'], |
||
147 | ]; |
||
148 | } |
||
149 | |||
150 | |||
151 | |||
152 | return $return; |
||
153 | } |
||
155 |
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