Total Complexity | 40 |
Total Lines | 609 |
Duplicated Lines | 0 % |
Changes | 8 | ||
Bugs | 0 | Features | 0 |
Complex classes like OrderLogistic 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.
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 OrderLogistic, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
26 | #[ApiResource( |
||
27 | operations: [ |
||
28 | new Get(security: 'is_granted(\'ROLE_CLIENT\')'), |
||
29 | new Put(security: 'is_granted(\'ROLE_CLIENT\')', denormalizationContext: ['groups' => ['logistic:write']]), |
||
30 | new GetCollection(security: 'is_granted(\'ROLE_CLIENT\')'), |
||
31 | new Delete(name: 'order_logistics_delete', security: 'is_granted(\'ROLE_CLIENT\')', denormalizationContext: ['groups' => ['logistic:write']]), |
||
32 | new Post(security: 'is_granted(\'ROLE_CLIENT\')', uriTemplate: '/order_logistics', denormalizationContext: ['groups' => ['logistic:write']]) |
||
33 | ], |
||
34 | formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
||
35 | security: 'is_granted(\'ROLE_CLIENT\')', |
||
36 | normalizationContext: ['groups' => ['logistic:read']], |
||
37 | denormalizationContext: ['groups' => ['logistic:write']], |
||
38 | )] |
||
39 | #[ApiFilter( |
||
40 | filterClass: DateFilter::class, |
||
41 | properties: [ |
||
42 | 'estimatedShippingDate', |
||
43 | 'shippingDate', |
||
44 | 'estimatedArrivalDate', |
||
45 | 'arrivalDate', |
||
46 | ], |
||
47 | )] |
||
48 | #[ApiFilter( |
||
49 | filterClass: SearchFilter::class, |
||
50 | properties: [ |
||
51 | 'order' => 'exact', |
||
52 | 'order.id' => 'exact', |
||
53 | 'order.contract.id' => 'exact', |
||
54 | 'order.client.name' => 'partial', |
||
55 | 'order.productType' => 'partial', |
||
56 | 'order.otherInformations' => 'partial', |
||
57 | 'originType' => 'exact', |
||
58 | 'originProvider' => 'exact', |
||
59 | 'originAddress' => 'partial', |
||
60 | 'originCity' => 'exact', |
||
61 | 'destinationType' => 'exact', |
||
62 | 'destinationProvider' => 'exact', |
||
63 | 'destinationAddress' => 'partial', |
||
64 | 'destinationCity' => 'exact', |
||
65 | 'status' => 'exact', |
||
66 | ] |
||
67 | )] |
||
68 | |||
69 | class OrderLogistic |
||
70 | { |
||
71 | /** |
||
72 | * @var int |
||
73 | * |
||
74 | * @ORM\Column(name="id", type="integer", nullable=false) |
||
75 | * @ORM\Id |
||
76 | * @ORM\GeneratedValue(strategy="IDENTITY") |
||
77 | * @Groups({"logistic:read"}) |
||
78 | */ |
||
79 | private $id; |
||
80 | /** |
||
81 | * @var \DateTime|null |
||
82 | * |
||
83 | * @ORM\Column(name="estimated_shipping_date", type="date", nullable=true) |
||
84 | * @Groups({"logistic:read","logistic:write"}) |
||
85 | */ |
||
86 | private $estimatedShippingDate = NULL; |
||
87 | /** |
||
88 | * @var \DateTime|null |
||
89 | * |
||
90 | * @ORM\Column(name="shipping_date", type="date", nullable=true) |
||
91 | * @Groups({"logistic:read","logistic:write"}) |
||
92 | */ |
||
93 | private $shippingDate = NULL; |
||
94 | /** |
||
95 | * @var \DateTime|null |
||
96 | * |
||
97 | * @ORM\Column(name="estimated_arrival_date", type="date", nullable=true) |
||
98 | * @Groups({"logistic:read","logistic:write"}) |
||
99 | */ |
||
100 | private $estimatedArrivalDate = NULL; |
||
101 | /** |
||
102 | * @var \DateTime|null |
||
103 | * |
||
104 | * @ORM\Column(name="arrival_date", type="date", nullable=true) |
||
105 | * @Groups({"logistic:read","logistic:write"}) |
||
106 | */ |
||
107 | private $arrivalDate = NULL; |
||
108 | /** |
||
109 | * @var \ControleOnline\Entity\Category |
||
110 | * |
||
111 | * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Category") |
||
112 | * @ORM\JoinColumns({ |
||
113 | * @ORM\JoinColumn(name="origin_type", referencedColumnName="id") |
||
114 | * }) |
||
115 | * @Groups({"logistic:read","logistic:write"}) |
||
116 | */ |
||
117 | private $originType; |
||
118 | |||
119 | /** |
||
120 | * @var \ControleOnline\Entity\City |
||
121 | * |
||
122 | * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\City") |
||
123 | * @ORM\JoinColumns({ |
||
124 | * @ORM\JoinColumn(name="origin_city_id", referencedColumnName="id") |
||
125 | * }) |
||
126 | * @Groups({"logistic:read","logistic:write"}) |
||
127 | */ |
||
128 | private $originCity = NULL; |
||
129 | |||
130 | /** |
||
131 | * @var string|null |
||
132 | * |
||
133 | * @ORM\Column(name="origin_address", type="string", length=150, nullable=true) |
||
134 | * @Groups({"logistic:read","logistic:write"}) |
||
135 | */ |
||
136 | private $originAddress = NULL; |
||
137 | |||
138 | /** |
||
139 | * @var float |
||
140 | * |
||
141 | * @ORM\Column(name="price", type="float", nullable=false) |
||
142 | * @Groups({"logistic:read","logistic:write"}) |
||
143 | */ |
||
144 | private $price = 0; |
||
145 | /** |
||
146 | * @var float |
||
147 | * |
||
148 | * @ORM\Column(name="amount_paid", type="float", nullable=false) |
||
149 | * @Groups({"logistic:read","logistic:write"}) |
||
150 | */ |
||
151 | private $amountPaid = 0; |
||
152 | /** |
||
153 | * @var float |
||
154 | * |
||
155 | * @ORM\Column(name="balance", type="float", nullable=false) |
||
156 | * @Groups({"logistic:read","logistic:write"}) |
||
157 | */ |
||
158 | private $balance = 0; |
||
159 | /** |
||
160 | * @var \Order |
||
161 | * |
||
162 | * @ORM\ManyToOne(targetEntity="Order") |
||
163 | * @ORM\JoinColumns({ |
||
164 | * @ORM\JoinColumn(name="order_id", referencedColumnName="id") |
||
165 | * }) |
||
166 | * @Groups({"logistic:read","logistic:write"}) |
||
167 | */ |
||
168 | private $order; |
||
169 | |||
170 | /** |
||
171 | * @var \People |
||
172 | * |
||
173 | * @ORM\ManyToOne(targetEntity="People") |
||
174 | * @ORM\JoinColumns({ |
||
175 | * @ORM\JoinColumn(name="origin_provider_id", referencedColumnName="id") |
||
176 | * }) |
||
177 | * @Groups({"logistic:read","logistic:write"}) |
||
178 | */ |
||
179 | private $originProvider; |
||
180 | /** |
||
181 | * @var \ControleOnline\Entity\Status |
||
182 | * |
||
183 | * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Status") |
||
184 | * @ORM\JoinColumns({ |
||
185 | * @ORM\JoinColumn(name="status_id", referencedColumnName="id") |
||
186 | * }) |
||
187 | * @Groups({"logistic:read","logistic:write"}) |
||
188 | */ |
||
189 | private $status; |
||
190 | /** |
||
191 | * @var \ControleOnline\Entity\Category |
||
192 | * |
||
193 | * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Category") |
||
194 | * @ORM\JoinColumns({ |
||
195 | * @ORM\JoinColumn(name="destination_type", referencedColumnName="id") |
||
196 | * }) |
||
197 | * @Groups({"logistic:read","logistic:write"}) |
||
198 | */ |
||
199 | private $destinationType; |
||
200 | |||
201 | /** |
||
202 | * @var \ControleOnline\Entity\City |
||
203 | * |
||
204 | * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\City") |
||
205 | * @ORM\JoinColumns({ |
||
206 | * @ORM\JoinColumn(name="destination_city_id", referencedColumnName="id") |
||
207 | * }) |
||
208 | * @Groups({"logistic:read","logistic:write"}) |
||
209 | */ |
||
210 | |||
211 | private $destinationCity = NULL; |
||
212 | /** |
||
213 | * @var string|null |
||
214 | * |
||
215 | * @ORM\Column(name="destination_address", type="string", length=150, nullable=true) |
||
216 | * @Groups({"logistic:read","logistic:write"}) |
||
217 | */ |
||
218 | private $destinationAddress = NULL; |
||
219 | |||
220 | /** |
||
221 | * @var \People |
||
222 | * |
||
223 | * @ORM\ManyToOne(targetEntity="People") |
||
224 | * @ORM\JoinColumns({ |
||
225 | * @ORM\JoinColumn(name="destination_provider_id", referencedColumnName="id") |
||
226 | * }) |
||
227 | * @Groups({"logistic:read","logistic:write"}) |
||
228 | */ |
||
229 | private $destinationProvider; |
||
230 | /** |
||
231 | * @var \People |
||
232 | * |
||
233 | * @ORM\ManyToOne(targetEntity="People") |
||
234 | * @ORM\JoinColumns({ |
||
235 | * @ORM\JoinColumn(name="created_by", referencedColumnName="id") |
||
236 | * }) |
||
237 | * @Groups({"logistic:read","logistic:write"}) |
||
238 | */ |
||
239 | private $created_by; |
||
240 | /** |
||
241 | * @var \DateTimeInterface |
||
242 | * @ORM\Column(name="last_modified", type="datetime", nullable=false, columnDefinition="DATETIME") |
||
243 | * @Groups({"logistic:read","logistic:write"}) |
||
244 | */ |
||
245 | private $lastModified; |
||
246 | |||
247 | /** |
||
248 | * Get the value of id |
||
249 | * |
||
250 | * @return int |
||
251 | */ |
||
252 | public function getId() |
||
253 | { |
||
254 | return $this->id; |
||
255 | } |
||
256 | /** |
||
257 | * Get the value of estimatedShippingDate |
||
258 | */ |
||
259 | public function getEstimatedShippingDate() |
||
260 | { |
||
261 | return $this->estimatedShippingDate; |
||
262 | } |
||
263 | |||
264 | /** |
||
265 | * Set the value of estimatedShippingDate |
||
266 | */ |
||
267 | public function setEstimatedShippingDate($estimatedShippingDate) |
||
268 | { |
||
269 | $this->estimatedShippingDate = $estimatedShippingDate; |
||
270 | |||
271 | return $this; |
||
272 | } |
||
273 | /** |
||
274 | * Get the value of shippingDate |
||
275 | * |
||
276 | * @return \DateTime|null |
||
277 | */ |
||
278 | public function getShippingDate() |
||
279 | { |
||
280 | return $this->shippingDate; |
||
281 | } |
||
282 | /** |
||
283 | * Set the value of shippingDate |
||
284 | * |
||
285 | * @param \DateTime|null $shippingDate |
||
286 | * |
||
287 | * @return self |
||
288 | */ |
||
289 | public function setShippingDate($shippingDate) |
||
290 | { |
||
291 | $this->shippingDate = $shippingDate; |
||
292 | return $this; |
||
293 | } |
||
294 | /** |
||
295 | * Get the value of estimatedArrivalDate |
||
296 | */ |
||
297 | public function getEstimatedArrivalDate() |
||
298 | { |
||
299 | return $this->estimatedArrivalDate; |
||
300 | } |
||
301 | |||
302 | /** |
||
303 | * Set the value of estimatedArrivalDate |
||
304 | */ |
||
305 | public function setEstimatedArrivalDate($estimatedArrivalDate) |
||
306 | { |
||
307 | $this->estimatedArrivalDate = $estimatedArrivalDate; |
||
308 | |||
309 | return $this; |
||
310 | } |
||
311 | /** |
||
312 | * Get the value of arrivalDate |
||
313 | * |
||
314 | * @return \DateTime|null |
||
315 | */ |
||
316 | public function getArrivalDate() |
||
317 | { |
||
318 | return $this->arrivalDate; |
||
319 | } |
||
320 | /** |
||
321 | * Set the value of arrivalDate |
||
322 | * |
||
323 | * @param \DateTime|null $arrivalDate |
||
324 | * |
||
325 | * @return self |
||
326 | */ |
||
327 | public function setArrivalDate($arrivalDate) |
||
328 | { |
||
329 | $this->arrivalDate = $arrivalDate; |
||
330 | return $this; |
||
331 | } |
||
332 | /** |
||
333 | * Get the value of originType |
||
334 | * |
||
335 | * @return string|null |
||
336 | */ |
||
337 | public function getOriginType() |
||
338 | { |
||
339 | return $this->originType; |
||
340 | } |
||
341 | /** |
||
342 | * Set the value of originType |
||
343 | * |
||
344 | * @param string|null $originType |
||
345 | * |
||
346 | * @return self |
||
347 | */ |
||
348 | public function setOriginType($originType) |
||
349 | { |
||
350 | $this->originType = $originType; |
||
351 | return $this; |
||
352 | } |
||
353 | |||
354 | /** |
||
355 | * Get the value of originCity |
||
356 | * |
||
357 | * @return string|null |
||
358 | */ |
||
359 | public function getOriginCity() |
||
360 | { |
||
361 | return $this->originCity; |
||
362 | } |
||
363 | /** |
||
364 | * Set the value of originCity |
||
365 | * |
||
366 | * @param string|null $originCity |
||
367 | * |
||
368 | * @return self |
||
369 | */ |
||
370 | public function setOriginCity($originCity) |
||
371 | { |
||
372 | $this->originCity = $originCity; |
||
373 | return $this; |
||
374 | } |
||
375 | /** |
||
376 | * Get the value of originAddress |
||
377 | * |
||
378 | * @return string|null |
||
379 | */ |
||
380 | public function getOriginAddress() |
||
381 | { |
||
382 | return $this->originAddress; |
||
383 | } |
||
384 | /** |
||
385 | * Set the value of originAddress |
||
386 | * |
||
387 | * @param string|null $originAddress |
||
388 | * |
||
389 | * @return self |
||
390 | */ |
||
391 | public function setOriginAddress($originAddress) |
||
392 | { |
||
393 | $this->originAddress = $originAddress; |
||
394 | return $this; |
||
395 | } |
||
396 | /** |
||
397 | * Get the value of price |
||
398 | * |
||
399 | * @return float |
||
400 | */ |
||
401 | public function getPrice() |
||
402 | { |
||
403 | return $this->price; |
||
404 | } |
||
405 | /** |
||
406 | * Set the value of price |
||
407 | * |
||
408 | * @param float $price |
||
409 | * |
||
410 | * @return self |
||
411 | */ |
||
412 | public function setPrice($price) |
||
413 | { |
||
414 | $this->price = $price ?: 0; |
||
415 | return $this; |
||
416 | } |
||
417 | /** |
||
418 | * Get order |
||
419 | * |
||
420 | * @return \ControleOnline\Entity\Order |
||
421 | */ |
||
422 | public function getOrder() |
||
423 | { |
||
424 | return $this->order; |
||
425 | } |
||
426 | /** |
||
427 | * Set order |
||
428 | * |
||
429 | * @param \ControleOnline\Entity\Order $order |
||
430 | */ |
||
431 | public function setOrder(\ControleOnline\Entity\Order $order) |
||
432 | { |
||
433 | $this->order = $order; |
||
434 | return $this; |
||
435 | } |
||
436 | /** |
||
437 | * Get the value of status |
||
438 | * |
||
439 | * @return \ControleOnline\Entity\Status |
||
440 | */ |
||
441 | public function getStatus() |
||
442 | { |
||
443 | return $this->status; |
||
444 | } |
||
445 | /** |
||
446 | * Set the value of status |
||
447 | * |
||
448 | * @param \ControleOnline\Entity\Status $status |
||
449 | * |
||
450 | * @return self |
||
451 | */ |
||
452 | public function setStatus(Status $status) |
||
453 | { |
||
454 | $this->status = $status; |
||
455 | return $this; |
||
456 | } |
||
457 | /** |
||
458 | * Get the value of destinationType |
||
459 | * |
||
460 | * @return string|null |
||
461 | */ |
||
462 | public function getDestinationType() |
||
463 | { |
||
464 | return $this->destinationType; |
||
465 | } |
||
466 | /** |
||
467 | * Set the value of destinationType |
||
468 | * |
||
469 | * @param string|null $destinationType |
||
470 | * |
||
471 | * @return self |
||
472 | */ |
||
473 | public function setDestinationType($destinationType) |
||
474 | { |
||
475 | $this->destinationType = $destinationType; |
||
476 | return $this; |
||
477 | } |
||
478 | /** |
||
479 | * Get the value of destinationCity |
||
480 | * |
||
481 | * @return string|null |
||
482 | */ |
||
483 | public function getDestinationCity() |
||
484 | { |
||
485 | return $this->destinationCity; |
||
486 | } |
||
487 | /** |
||
488 | * Set the value of destinationCity |
||
489 | * |
||
490 | * @param string|null $destinationCity |
||
491 | * |
||
492 | * @return self |
||
493 | */ |
||
494 | public function setDestinationCity($destinationCity) |
||
495 | { |
||
496 | $this->destinationCity = $destinationCity; |
||
497 | return $this; |
||
498 | } |
||
499 | /** |
||
500 | * Get the value of destinationAddress |
||
501 | * |
||
502 | * @return string|null |
||
503 | */ |
||
504 | public function getDestinationAddress() |
||
505 | { |
||
506 | return $this->destinationAddress; |
||
507 | } |
||
508 | /** |
||
509 | * Set the value of destinationAddress |
||
510 | * |
||
511 | * @param string|null $destinationAddress |
||
512 | * |
||
513 | * @return self |
||
514 | */ |
||
515 | public function setDestinationAddress($destinationAddress) |
||
516 | { |
||
517 | $this->destinationAddress = $destinationAddress; |
||
518 | return $this; |
||
519 | } |
||
520 | /** |
||
521 | * Get the value of destinationProvider |
||
522 | * |
||
523 | * @return \People |
||
524 | */ |
||
525 | public function getDestinationProvider() |
||
526 | { |
||
527 | return $this->destinationProvider; |
||
528 | } |
||
529 | /** |
||
530 | * Set the value of destinationProvider |
||
531 | * |
||
532 | * @param \People $destinationProvider |
||
533 | * |
||
534 | * @return self |
||
535 | */ |
||
536 | public function setDestinationProvider(?\ControleOnline\Entity\People $destinationProvider) |
||
540 | } |
||
541 | /** |
||
542 | * Get the value of lastModified |
||
543 | * |
||
544 | * @return \DateTimeInterface |
||
545 | */ |
||
546 | public function getLastModified() |
||
547 | { |
||
548 | return $this->lastModified; |
||
549 | } |
||
550 | /** |
||
551 | * Set the value of lastModified |
||
552 | * |
||
553 | * @param \DateTimeInterface $lastModified |
||
554 | * |
||
555 | * @return self |
||
556 | */ |
||
557 | public function setLastModified(\DateTimeInterface $lastModified) |
||
558 | { |
||
559 | $this->lastModified = $lastModified; |
||
560 | return $this; |
||
561 | } |
||
562 | /** |
||
563 | * Get the value of amountPaid |
||
564 | * |
||
565 | * @return int |
||
566 | */ |
||
567 | public function getAmountPaid() |
||
568 | { |
||
569 | return $this->amountPaid; |
||
570 | } |
||
571 | /** |
||
572 | * Set the value of amountPaid |
||
573 | * |
||
574 | * @param int $amountPaid |
||
575 | * |
||
576 | * @return self |
||
577 | */ |
||
578 | public function setAmountPaid($amountPaid) |
||
579 | { |
||
580 | $this->amountPaid = $amountPaid; |
||
581 | return $this; |
||
582 | } |
||
583 | /** |
||
584 | * Get the value of balance |
||
585 | */ |
||
586 | public function getBalance() |
||
587 | { |
||
588 | return $this->balance; |
||
589 | } |
||
590 | |||
591 | /** |
||
592 | * Set the value of balance |
||
593 | */ |
||
594 | public function setBalance($balance) |
||
595 | { |
||
596 | $this->balance = $balance; |
||
597 | |||
598 | return $this; |
||
599 | } |
||
600 | |||
601 | /** |
||
602 | * Get the value of created_by |
||
603 | */ |
||
604 | public function getCreatedBy() |
||
605 | { |
||
606 | return $this->created_by; |
||
607 | } |
||
608 | |||
609 | /** |
||
610 | * Set the value of created_by |
||
611 | */ |
||
612 | public function setCreatedBy($created_by): self |
||
613 | { |
||
614 | $this->created_by = $created_by; |
||
615 | |||
616 | return $this; |
||
617 | } |
||
618 | |||
619 | /** |
||
620 | * Get the value of originProvider |
||
621 | */ |
||
622 | public function getOriginProvider() |
||
625 | } |
||
626 | |||
627 | /** |
||
628 | * Set the value of originProvider |
||
629 | */ |
||
630 | public function setOriginProvider($originProvider): self |
||
631 | { |
||
632 | $this->originProvider = $originProvider; |
||
633 | |||
634 | return $this; |
||
635 | } |
||
636 | } |
||
637 |
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