Conditions | 5 |
Paths | 5 |
Total Lines | 103 |
Code Lines | 77 |
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 |
||
107 | public function getSalesmanClientCollection(string $type, string $fromDate, string $toDate, People $provider, People $salesman) |
||
108 | { |
||
109 | $queryBuilder = $this->createQueryBuilder('myclients'); |
||
110 | |||
111 | switch ($type) { |
||
112 | |||
113 | case 'active': |
||
114 | |||
115 | $queryBuilder->innerJoin(Order::class, 'O' , 'WITH', 'O.client = myclients.id'); |
||
116 | $queryBuilder->innerJoin(People::class, 'C' , 'WITH', 'C.id = O.provider'); |
||
117 | $queryBuilder->innerJoin(PeopleSalesman::class, 'kkk', 'WITH', 'kkk.company = C.id'); |
||
118 | $queryBuilder->innerJoin(People::class, 'S' , 'WITH', 'S.id = kkk.salesman'); |
||
119 | $queryBuilder->innerJoin(PeopleClient::class, 'PC' , 'WITH', 'PC.client = myclients.id AND PC.company_id = S.id'); |
||
120 | $queryBuilder->andWhere('O.provider = :provider'); |
||
121 | $queryBuilder->andWhere('S.id IN (:my_companies)'); |
||
122 | $queryBuilder->andWhere('O.status NOT IN (:statuses)'); |
||
123 | $queryBuilder->andWhere('O.orderDate BETWEEN :from_date AND :to_date'); |
||
124 | $queryBuilder->setParameter('provider' , $provider); |
||
125 | $queryBuilder->setParameter('statuses' , $this->getEntityManager()->getRepository(Status::class)->findBy(['realStatus' => ['open','canceled']])); |
||
126 | $queryBuilder->setParameter('from_date' , $fromDate); |
||
127 | $queryBuilder->setParameter('to_date' , $toDate); |
||
128 | $queryBuilder->setParameter('my_companies', $this->getMyCompanies($salesman)); |
||
129 | |||
130 | break; |
||
131 | |||
132 | case 'inactive': |
||
133 | |||
134 | $queryBuilder->innerJoin(Order::class, 'O' , 'WITH', 'O.client = myclients.id'); |
||
135 | $queryBuilder->innerJoin(People::class, 'C' , 'WITH', 'C.id = O.provider'); |
||
136 | $queryBuilder->innerJoin(PeopleSalesman::class, 'kkk', 'WITH', 'kkk.company = C.id'); |
||
137 | $queryBuilder->innerJoin(People::class, 'S' , 'WITH', 'S.id = kkk.salesman'); |
||
138 | $queryBuilder->innerJoin(PeopleClient::class, 'PC' , 'WITH', 'PC.client = myclients.id AND PC.company_id = S.id'); |
||
139 | $queryBuilder->leftJoin (Order::class, 'jj' , 'WITH', 'jj.client = myclients.id |
||
140 | AND (jj.status NOT IN (:statuses) OR jj.id IS NULL) |
||
141 | AND ((jj.orderDate BETWEEN :from_date AND :to_date) OR jj.id IS NULL) |
||
142 | AND (jj.provider = :provider OR jj.id IS NULL)'); |
||
143 | $queryBuilder->andWhere('O.provider = :provider'); |
||
144 | $queryBuilder->andWhere('S.id IN (:my_companies)'); |
||
145 | $queryBuilder->andWhere('O.status NOT IN (:statuses)'); |
||
146 | $queryBuilder->andWhere('O.orderDate NOT BETWEEN :from_date AND :to_date'); |
||
147 | $queryBuilder->groupBy('myclients.id'); |
||
148 | $queryBuilder->having('COUNT(jj.id) > :count'); |
||
149 | $queryBuilder->andHaving('COUNT(O.id) = :count'); |
||
150 | $queryBuilder->setParameter('provider' , $provider); |
||
151 | $queryBuilder->setParameter('statuses' , $this->getEntityManager()->getRepository(Status::class)->findBy(['realStatus' => ['open','canceled']])); |
||
152 | $queryBuilder->setParameter('from_date', $fromDate); |
||
153 | $queryBuilder->setParameter('to_date' , $toDate); |
||
154 | $queryBuilder->setParameter('count' , 0); |
||
155 | $queryBuilder->setParameter('my_companies', $this->getMyCompanies($salesman)); |
||
156 | |||
157 | break; |
||
158 | |||
159 | case 'prospect': |
||
160 | |||
161 | $queryBuilder->innerJoin(Order::class, 'O' , 'WITH', 'O.client = myclients.id'); |
||
162 | $queryBuilder->innerJoin(People::class, 'C' , 'WITH', 'C.id = O.provider'); |
||
163 | $queryBuilder->innerJoin(PeopleSalesman::class, 'PS', 'WITH', 'PS.company = C.id'); |
||
164 | $queryBuilder->innerJoin(People::class, 'S' , 'WITH', 'S.id = PS.salesman'); |
||
165 | $queryBuilder->innerJoin(PeopleClient::class, 'PC', 'WITH', 'PC.client = myclients.id AND PC.company_id = S.id'); |
||
166 | $queryBuilder->leftJoin (Order::class, 'jj' , 'WITH', 'jj.client = myclients.id |
||
167 | AND (jj.status NOT IN (:statuses) OR jj.id IS NULL) |
||
168 | AND (jj.provider = :provider OR jj.id IS NULL)'); |
||
169 | $queryBuilder->andWhere('O.provider = :provider'); |
||
170 | $queryBuilder->andWhere('S.id IN (:my_companies)'); |
||
171 | $queryBuilder->andWhere('O.status NOT IN (:statuses)'); |
||
172 | $queryBuilder->groupBy('myclients.id'); |
||
173 | $queryBuilder->having('COUNT(jj.id) = :count'); |
||
174 | |||
175 | $queryBuilder->setParameter('provider', $provider); |
||
176 | $queryBuilder->setParameter('statuses', $this->getEntityManager()->getRepository(Status::class)->findBy(['realStatus' => ['open','canceled']])); |
||
177 | $queryBuilder->setParameter('count' , 0); |
||
178 | $queryBuilder->setParameter('my_companies', $this->getMyCompanies($salesman)); |
||
179 | |||
180 | break; |
||
181 | |||
182 | case 'new': |
||
183 | |||
184 | $queryBuilder->innerJoin(Order::class, 'O' , 'WITH', 'O.client = myclients.id'); |
||
185 | $queryBuilder->innerJoin(People::class, 'C' , 'WITH', 'C.id = O.provider'); |
||
186 | $queryBuilder->innerJoin(PeopleSalesman::class, 'kkk', 'WITH', 'kkk.company = C.id'); |
||
187 | $queryBuilder->innerJoin(People::class, 'S' , 'WITH', 'S.id = kkk.salesman'); |
||
188 | $queryBuilder->innerJoin(PeopleClient::class, 'PC' , 'WITH', 'PC.client = myclients.id AND PC.company_id = S.id'); |
||
189 | |||
190 | $queryBuilder->andWhere('O.provider = :provider'); |
||
191 | $queryBuilder->andWhere('S.id IN (:my_companies)'); |
||
192 | $queryBuilder->andWhere('O.status NOT IN (:statuses)'); |
||
193 | $queryBuilder->andWhere('O.orderDate BETWEEN :from_date AND :to_date'); |
||
194 | $queryBuilder->andWhere('myclients.registerDate BETWEEN :from_date AND :to_date'); |
||
195 | |||
196 | $queryBuilder->setParameter('provider' , $provider); |
||
197 | $queryBuilder->setParameter('statuses' , $this->getEntityManager()->getRepository(Status::class)->findBy(['realStatus' => ['open','canceled']])); |
||
198 | $queryBuilder->setParameter('from_date' , $fromDate); |
||
199 | $queryBuilder->setParameter('to_date' , $toDate); |
||
200 | $queryBuilder->setParameter('my_companies', $this->getMyCompanies($salesman)); |
||
201 | |||
202 | break; |
||
203 | |||
204 | default: |
||
205 | $queryBuilder->andWhere('myclients.id = 0'); |
||
206 | break; |
||
207 | } |
||
208 | |||
209 | return $queryBuilder->getQuery()->getResult(); |
||
210 | } |
||
233 |
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