Total Complexity | 58 |
Total Lines | 775 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like Part 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 Part, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
82 | class Part extends AttachmentContainingDBElement |
||
83 | { |
||
84 | public const INSTOCK_UNKNOWN = -2; |
||
85 | |||
86 | /** |
||
87 | * @ORM\OneToMany(targetEntity="App\Entity\Attachments\PartAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) |
||
88 | * @Assert\Valid() |
||
89 | */ |
||
90 | protected $attachments; |
||
91 | |||
92 | /** |
||
93 | * @var Category |
||
94 | * @ORM\ManyToOne(targetEntity="Category", inversedBy="parts") |
||
95 | * @ORM\JoinColumn(name="id_category", referencedColumnName="id") |
||
96 | * @Selectable() |
||
97 | */ |
||
98 | protected $category; |
||
99 | |||
100 | /** |
||
101 | * @var Footprint|null |
||
102 | * @ORM\ManyToOne(targetEntity="Footprint", inversedBy="parts") |
||
103 | * @ORM\JoinColumn(name="id_footprint", referencedColumnName="id") |
||
104 | * |
||
105 | * @ColumnSecurity(prefix="footprint", type="object") |
||
106 | * @Selectable() |
||
107 | */ |
||
108 | protected $footprint; |
||
109 | |||
110 | /** |
||
111 | * @var Manufacturer|null |
||
112 | * @ORM\ManyToOne(targetEntity="Manufacturer", inversedBy="parts") |
||
113 | * @ORM\JoinColumn(name="id_manufacturer", referencedColumnName="id") |
||
114 | * |
||
115 | * @ColumnSecurity(prefix="manufacturer", type="object") |
||
116 | * @Selectable() |
||
117 | */ |
||
118 | protected $manufacturer; |
||
119 | |||
120 | /** |
||
121 | * @var Attachment |
||
122 | * @ORM\ManyToOne(targetEntity="App\Entity\Attachments\Attachment") |
||
123 | * @ORM\JoinColumn(name="id_master_picture_attachement", referencedColumnName="id") |
||
124 | * |
||
125 | * @ColumnSecurity(prefix="attachments", type="object") |
||
126 | */ |
||
127 | protected $master_picture_attachment; |
||
128 | |||
129 | /** |
||
130 | * @var Orderdetail[] |
||
131 | * @ORM\OneToMany(targetEntity="App\Entity\PriceInformations\Orderdetail", mappedBy="part", cascade={"persist", "remove"}, orphanRemoval=true) |
||
132 | * @Assert\Valid() |
||
133 | * @ColumnSecurity(prefix="orderdetails", type="object") |
||
134 | */ |
||
135 | protected $orderdetails; |
||
136 | |||
137 | /** |
||
138 | * @var Orderdetail |
||
139 | * @ORM\OneToOne(targetEntity="App\Entity\PriceInformations\Orderdetail") |
||
140 | * @ORM\JoinColumn(name="order_orderdetails_id", referencedColumnName="id") |
||
141 | * |
||
142 | * @ColumnSecurity(prefix="order", type="object") |
||
143 | */ |
||
144 | protected $order_orderdetail; |
||
145 | |||
146 | //TODO |
||
147 | protected $devices; |
||
148 | |||
149 | /** |
||
150 | * @ColumnSecurity(type="datetime") |
||
151 | * @ORM\Column(type="datetimetz", name="datetime_added") |
||
152 | */ |
||
153 | protected $addedDate; |
||
154 | |||
155 | /** |
||
156 | * @var \DateTime The date when this element was modified the last time. |
||
157 | * @ORM\Column(type="datetimetz", name="last_modified") |
||
158 | * @ColumnSecurity(type="datetime") |
||
159 | */ |
||
160 | protected $lastModified; |
||
161 | |||
162 | /********************** |
||
163 | * Propertys |
||
164 | ***********************/ |
||
165 | |||
166 | /** |
||
167 | * @var string |
||
168 | * @ORM\Column(type="string") |
||
169 | * |
||
170 | * @ColumnSecurity(prefix="name") |
||
171 | */ |
||
172 | protected $name = ''; |
||
173 | |||
174 | /** |
||
175 | * @var string |
||
176 | * @ORM\Column(type="text") |
||
177 | * |
||
178 | * @ColumnSecurity(prefix="description") |
||
179 | */ |
||
180 | protected $description = ''; |
||
181 | |||
182 | /** |
||
183 | * @var ?PartLot[] |
||
184 | * @ORM\OneToMany(targetEntity="PartLot", mappedBy="part", cascade={"persist", "remove"}, orphanRemoval=true) |
||
185 | * @Assert\Valid() |
||
186 | */ |
||
187 | protected $partLots; |
||
188 | |||
189 | /** |
||
190 | * @var float |
||
191 | * @ORM\Column(type="float") |
||
192 | * @Assert\PositiveOrZero() |
||
193 | * |
||
194 | * @ColumnSecurity(prefix="mininstock", type="integer") |
||
195 | */ |
||
196 | protected $minamount = 0; |
||
197 | |||
198 | /** |
||
199 | * @var string |
||
200 | * @ORM\Column(type="text") |
||
201 | * @ColumnSecurity(prefix="comment") |
||
202 | */ |
||
203 | protected $comment = ''; |
||
204 | |||
205 | /** |
||
206 | * @var bool |
||
207 | * @ORM\Column(type="boolean") |
||
208 | */ |
||
209 | protected $visible = true; |
||
210 | |||
211 | /** |
||
212 | * @var bool |
||
213 | * @ORM\Column(type="boolean") |
||
214 | * @ColumnSecurity(type="boolean") |
||
215 | */ |
||
216 | protected $favorite = false; |
||
217 | |||
218 | /** |
||
219 | * @var int |
||
220 | * @ORM\Column(type="integer") |
||
221 | * @ColumnSecurity(prefix="order", type="integer") |
||
222 | */ |
||
223 | protected $order_quantity = 0; |
||
224 | |||
225 | /** |
||
226 | * @var bool |
||
227 | * @ORM\Column(type="boolean") |
||
228 | * @ColumnSecurity(prefix="order", type="boolean") |
||
229 | */ |
||
230 | protected $manual_order = false; |
||
231 | |||
232 | /** |
||
233 | * @var string |
||
234 | * @ORM\Column(type="string") |
||
235 | * @ColumnSecurity(prefix="manufacturer", type="string", placeholder="") |
||
236 | */ |
||
237 | protected $manufacturer_product_url = ''; |
||
238 | |||
239 | /** |
||
240 | * @var string |
||
241 | * @ORM\Column(type="string") |
||
242 | * @ColumnSecurity(prefix="manufacturer", type="string", placeholder="") |
||
243 | */ |
||
244 | protected $manufacturer_product_number = ''; |
||
245 | |||
246 | /** |
||
247 | * @var string |
||
248 | * @ORM\Column(type="string", length=255, nullable=true) |
||
249 | */ |
||
250 | protected $manufacturing_status; |
||
251 | |||
252 | /** |
||
253 | * @var bool Determines if this part entry needs review (for example, because it is work in progress) |
||
254 | * @ORM\Column(type="boolean") |
||
255 | */ |
||
256 | protected $needs_review = false; |
||
257 | |||
258 | /** |
||
259 | * @var ?MeasurementUnit The unit in which the part's amount is measured. |
||
260 | * @ORM\ManyToOne(targetEntity="MeasurementUnit") |
||
261 | * @ORM\JoinColumn(name="id_part_unit", referencedColumnName="id", nullable=true) |
||
262 | */ |
||
263 | protected $partUnit; |
||
264 | |||
265 | /** |
||
266 | * @var string A comma seperated list of tags, assocciated with the part. |
||
267 | * @ORM\Column(type="text") |
||
268 | */ |
||
269 | protected $tags = ''; |
||
270 | |||
271 | /** |
||
272 | * @var float|null How much a single part unit weighs in gramms. |
||
273 | * @ORM\Column(type="float", nullable=true) |
||
274 | * @Assert\PositiveOrZero() |
||
275 | */ |
||
276 | protected $mass; |
||
277 | |||
278 | public function __construct() |
||
279 | { |
||
280 | parent::__construct(); |
||
281 | $this->partLots = new ArrayCollection(); |
||
|
|||
282 | $this->orderdetails = new ArrayCollection(); |
||
283 | } |
||
284 | |||
285 | /** |
||
286 | * Returns the ID as an string, defined by the element class. |
||
287 | * This should have a form like P000014, for a part with ID 14. |
||
288 | * |
||
289 | * @return string The ID as a string; |
||
290 | */ |
||
291 | public function getIDString(): string |
||
292 | { |
||
293 | return 'P' . sprintf('%06d', $this->getID()); |
||
294 | } |
||
295 | |||
296 | /********************************************************************************* |
||
297 | * Getters |
||
298 | ********************************************************************************/ |
||
299 | |||
300 | /** |
||
301 | * Get the description string like it is saved in the database. |
||
302 | * This can contain BBCode, it is not parsed yet. |
||
303 | * |
||
304 | * @return string the description |
||
305 | */ |
||
306 | public function getDescription(): string |
||
307 | { |
||
308 | return htmlspecialchars($this->description); |
||
309 | } |
||
310 | |||
311 | /** |
||
312 | * Get the count of parts which must be in stock at least. |
||
313 | * If a integer-based part unit is selected, the value will be rounded to integers |
||
314 | * |
||
315 | * @return float count of parts which must be in stock at least |
||
316 | */ |
||
317 | public function getMinAmount(): float |
||
318 | { |
||
319 | if ($this->useFloatAmount()) { |
||
320 | return $this->minamount; |
||
321 | } |
||
322 | |||
323 | return round($this->minamount); |
||
324 | |||
325 | } |
||
326 | |||
327 | /** |
||
328 | * Get the comment associated with this part. |
||
329 | * |
||
330 | * @return string The raw/unparsed comment |
||
331 | */ |
||
332 | public function getComment(): string |
||
333 | { |
||
334 | return htmlspecialchars($this->comment); |
||
335 | } |
||
336 | |||
337 | /** |
||
338 | * Get if this part is obsolete. |
||
339 | * |
||
340 | * A Part is marked as "obsolete" if all their orderdetails are marked as "obsolete". |
||
341 | * If a part has no orderdetails, the part isn't marked as obsolete. |
||
342 | * |
||
343 | * @return bool true, if this part is obsolete. false, if this part isn't obsolete |
||
344 | */ |
||
345 | public function isObsolete(): bool |
||
346 | { |
||
347 | $all_orderdetails = $this->getOrderdetails(); |
||
348 | |||
349 | if (0 === count($all_orderdetails)) { |
||
350 | return false; |
||
351 | } |
||
352 | |||
353 | foreach ($all_orderdetails as $orderdetails) { |
||
354 | if (!$orderdetails->getObsolete()) { |
||
355 | return false; |
||
356 | } |
||
357 | } |
||
358 | |||
359 | return true; |
||
360 | } |
||
361 | |||
362 | /** |
||
363 | * Get if this part is visible. |
||
364 | * |
||
365 | * @return bool true if this part is visible |
||
366 | * false if this part isn't visible |
||
367 | */ |
||
368 | public function isVisible(): bool |
||
369 | { |
||
370 | return $this->visible; |
||
371 | } |
||
372 | |||
373 | /** |
||
374 | * Get if this part is a favorite. |
||
375 | * |
||
376 | * @return bool * true if this part is a favorite |
||
377 | * * false if this part is not a favorite. |
||
378 | */ |
||
379 | public function isFavorite(): bool |
||
380 | { |
||
381 | return $this->favorite; |
||
382 | } |
||
383 | |||
384 | /** |
||
385 | * Get the selected order orderdetails of this part. |
||
386 | * @return Orderdetail the selected order orderdetails |
||
387 | */ |
||
388 | public function getOrderOrderdetails(): ?Orderdetail |
||
389 | { |
||
390 | return $this->order_orderdetail; |
||
391 | } |
||
392 | |||
393 | /** |
||
394 | * Get the order quantity of this part. |
||
395 | * |
||
396 | * @return int the order quantity |
||
397 | */ |
||
398 | public function getOrderQuantity(): int |
||
399 | { |
||
400 | return $this->order_quantity; |
||
401 | } |
||
402 | |||
403 | /** |
||
404 | * Check if this part is marked for manual ordering. |
||
405 | * |
||
406 | * @return bool the "manual_order" attribute |
||
407 | */ |
||
408 | public function isMarkedForManualOrder(): bool |
||
409 | { |
||
410 | return $this->manual_order; |
||
411 | } |
||
412 | |||
413 | /** |
||
414 | * Get the link to the website of the article on the manufacturers website |
||
415 | * When no this part has no explicit url set, then it is tried to generate one from the Manufacturer of this part |
||
416 | * automatically. |
||
417 | * |
||
418 | * @param |
||
419 | * |
||
420 | * @return string the link to the article |
||
421 | */ |
||
422 | public function getManufacturerProductUrl(): string |
||
433 | } |
||
434 | |||
435 | /** |
||
436 | * Similar to getManufacturerProductUrl, but here only the database value is returned. |
||
437 | * |
||
438 | * @return string The manufacturer url saved in DB for this part. |
||
439 | */ |
||
440 | public function getCustomProductURL(): string |
||
441 | { |
||
442 | return $this->manufacturer_product_url; |
||
443 | } |
||
444 | |||
445 | /** |
||
446 | * Get the category of this part. |
||
447 | * |
||
448 | * There is always a category, for each part! |
||
449 | * |
||
450 | * @return Category the category of this part |
||
451 | */ |
||
452 | public function getCategory(): Category |
||
453 | { |
||
454 | return $this->category; |
||
455 | } |
||
456 | |||
457 | /** |
||
458 | * Get the footprint of this part (if there is one). |
||
459 | * |
||
460 | * @return Footprint the footprint of this part (if there is one) |
||
461 | */ |
||
462 | public function getFootprint(): ?Footprint |
||
463 | { |
||
464 | return $this->footprint; |
||
465 | } |
||
466 | |||
467 | /** |
||
468 | * Get the manufacturer of this part (if there is one). |
||
469 | * |
||
470 | * @return Manufacturer the manufacturer of this part (if there is one) |
||
471 | */ |
||
472 | public function getManufacturer(): ?Manufacturer |
||
473 | { |
||
474 | return $this->manufacturer; |
||
475 | } |
||
476 | |||
477 | /** |
||
478 | * Get the master picture "Attachement"-object of this part (if there is one). |
||
479 | * |
||
480 | * @return Attachment the master picture Attachement of this part (if there is one) |
||
481 | */ |
||
482 | public function getMasterPictureAttachement(): ?Attachment |
||
483 | { |
||
484 | return $this->master_picture_attachment; |
||
485 | } |
||
486 | |||
487 | /** |
||
488 | * Get all orderdetails of this part. |
||
489 | * |
||
490 | * @param bool $hide_obsolete If true, obsolete orderdetails will NOT be returned |
||
491 | * |
||
492 | * @return Collection|Orderdetail[] * all orderdetails as a one-dimensional array of Orderdetails objects |
||
493 | * (empty array if there are no ones) |
||
494 | * * the array is sorted by the suppliers names / minimum order quantity |
||
495 | * |
||
496 | */ |
||
497 | public function getOrderdetails(bool $hide_obsolete = false) : Collection |
||
498 | { |
||
499 | //If needed hide the obsolete entries |
||
500 | if ($hide_obsolete) { |
||
501 | $orderdetails = $this->orderdetails; |
||
502 | foreach ($orderdetails as $key => $details) { |
||
503 | if ($details->getObsolete()) { |
||
504 | unset($orderdetails[$key]); |
||
505 | } |
||
506 | } |
||
507 | |||
508 | return $orderdetails; |
||
509 | } |
||
510 | |||
511 | return $this->orderdetails; |
||
512 | } |
||
513 | |||
514 | public function addOrderdetail(Orderdetail $orderdetail) : Part |
||
515 | { |
||
516 | $orderdetail->setPart($this); |
||
517 | $this->orderdetails->add($orderdetail); |
||
518 | return $this; |
||
519 | } |
||
520 | |||
521 | public function removeOrderdetail(Orderdetail $orderdetail) : Part |
||
522 | { |
||
523 | $this->orderdetails->removeElement($orderdetail); |
||
524 | return $this; |
||
525 | } |
||
526 | |||
527 | /** |
||
528 | * Get all devices which uses this part. |
||
529 | * |
||
530 | * @return Device[] * all devices which uses this part as a one-dimensional array of Device objects |
||
531 | * (empty array if there are no ones) |
||
532 | * * the array is sorted by the devices names |
||
533 | * |
||
534 | */ |
||
535 | public function getDevices(): array |
||
536 | { |
||
537 | return $this->devices; |
||
538 | } |
||
539 | |||
540 | /** |
||
541 | * Checks if this part is marked, for that it needs further review. |
||
542 | * @return bool |
||
543 | */ |
||
544 | public function isNeedsReview(): bool |
||
545 | { |
||
546 | return $this->needs_review; |
||
547 | } |
||
548 | |||
549 | /** |
||
550 | * Sets the "needs review" status of this part. |
||
551 | * @param bool $needs_review |
||
552 | * @return Part |
||
553 | */ |
||
554 | public function setNeedsReview(bool $needs_review): Part |
||
555 | { |
||
556 | $this->needs_review = $needs_review; |
||
557 | return $this; |
||
558 | } |
||
559 | |||
560 | /** |
||
561 | * Get all part lots where this part is stored. |
||
562 | * @return PartLot[]|Collection |
||
563 | */ |
||
564 | public function getPartLots() : Collection |
||
565 | { |
||
566 | return $this->partLots; |
||
567 | } |
||
568 | |||
569 | public function addPartLot(PartLot $lot): Part |
||
570 | { |
||
571 | $lot->setPart($this); |
||
572 | $this->partLots->add($lot); |
||
573 | return $this; |
||
574 | } |
||
575 | |||
576 | public function removePartLot(PartLot $lot): Part |
||
577 | { |
||
578 | $this->partLots->removeElement($lot); |
||
579 | return $this; |
||
580 | } |
||
581 | |||
582 | /** |
||
583 | * Returns the assigned manufacturer product number (MPN) for this part. |
||
584 | * @return string |
||
585 | */ |
||
586 | public function getManufacturerProductNumber(): string |
||
587 | { |
||
588 | return $this->manufacturer_product_number; |
||
589 | } |
||
590 | |||
591 | /** |
||
592 | * Sets the manufacturer product number (MPN) for this part. |
||
593 | * @param string $manufacturer_product_number |
||
594 | * @return Part |
||
595 | */ |
||
596 | public function setManufacturerProductNumber(string $manufacturer_product_number): Part |
||
597 | { |
||
598 | $this->manufacturer_product_number = $manufacturer_product_number; |
||
599 | return $this; |
||
600 | } |
||
601 | |||
602 | /** |
||
603 | * Gets the measurement unit in which the part's amount should be measured. |
||
604 | * Returns null if no specific unit was that. That means the parts are measured simply in quantity numbers. |
||
605 | * @return MeasurementUnit|null |
||
606 | */ |
||
607 | public function getPartUnit(): ?MeasurementUnit |
||
608 | { |
||
609 | return $this->partUnit; |
||
610 | } |
||
611 | |||
612 | /** |
||
613 | * Sets the measurement unit in which the part's amount should be measured. |
||
614 | * Set to null, if the part should be measured in quantities. |
||
615 | * @param MeasurementUnit|null $partUnit |
||
616 | * @return Part |
||
617 | */ |
||
618 | public function setPartUnit(?MeasurementUnit $partUnit): Part |
||
619 | { |
||
620 | $this->partUnit = $partUnit; |
||
621 | return $this; |
||
622 | } |
||
623 | |||
624 | /** |
||
625 | * Gets a comma separated list, of tags, that are assigned to this part |
||
626 | * @return string |
||
627 | */ |
||
628 | public function getTags(): string |
||
629 | { |
||
630 | return $this->tags; |
||
631 | } |
||
632 | |||
633 | /** |
||
634 | * Sets a comma separated list of tags, that are assigned to this part. |
||
635 | * @param string $tags |
||
636 | * @return Part |
||
637 | */ |
||
638 | public function setTags(string $tags): Part |
||
639 | { |
||
640 | $this->tags = $tags; |
||
641 | return $this; |
||
642 | } |
||
643 | |||
644 | /** |
||
645 | * Returns the mass of a single part unit. |
||
646 | * Returns null, if the mass is unknown/not set yet |
||
647 | * @return float|null |
||
648 | */ |
||
649 | public function getMass(): ?float |
||
650 | { |
||
651 | return $this->mass; |
||
652 | } |
||
653 | |||
654 | /** |
||
655 | * Sets the mass of a single part unit. |
||
656 | * Sett to null, if the mass is unknown. |
||
657 | * @param float|null $mass |
||
658 | * @return Part |
||
659 | */ |
||
660 | public function setMass(?float $mass): Part |
||
661 | { |
||
662 | $this->mass = $mass; |
||
663 | return $this; |
||
664 | } |
||
665 | |||
666 | /** |
||
667 | * Checks if this part uses the float amount . |
||
668 | * This setting is based on the part unit (see MeasurementUnit->isInteger()). |
||
669 | * @return bool True if the float amount field should be used. False if the integer instock field should be used. |
||
670 | */ |
||
671 | public function useFloatAmount(): bool |
||
672 | { |
||
673 | if ($this->partUnit instanceof MeasurementUnit) { |
||
674 | return !$this->partUnit->isInteger(); |
||
675 | } |
||
676 | |||
677 | //When no part unit is set, treat it as part count, and so use the integer value. |
||
678 | return false; |
||
679 | } |
||
680 | |||
681 | /** |
||
682 | * Returns the summed amount of this part (over all part lots) |
||
683 | * @return float |
||
684 | */ |
||
685 | public function getAmountSum() : float |
||
686 | { |
||
687 | //TODO: Find a method to do this natively in SQL, the current method could be a bit slow |
||
688 | $sum = 0; |
||
689 | foreach ($this->getPartLots() as $lot) { |
||
690 | //Dont use the instock value, if it is unkown |
||
691 | if ($lot->isInstockUnknown()) { |
||
692 | continue; |
||
693 | } |
||
694 | |||
695 | $sum += $lot->getAmount(); |
||
696 | } |
||
697 | |||
698 | if ($this->useFloatAmount()) { |
||
699 | return $sum; |
||
700 | } |
||
701 | |||
702 | return round($sum); |
||
703 | } |
||
704 | |||
705 | /******************************************************************************** |
||
706 | * |
||
707 | * Setters |
||
708 | * |
||
709 | *********************************************************************************/ |
||
710 | |||
711 | /** |
||
712 | * Set the description. |
||
713 | * |
||
714 | * @param string $new_description the new description |
||
715 | * |
||
716 | * @return self |
||
717 | */ |
||
718 | public function setDescription(?string $new_description): self |
||
719 | { |
||
720 | $this->description = $new_description; |
||
721 | |||
722 | return $this; |
||
723 | } |
||
724 | |||
725 | /** |
||
726 | * Set the minimum amount of parts that have to be instock. |
||
727 | * See getPartUnit() for the associated unit. |
||
728 | * |
||
729 | * @param int $new_minamount the new count of parts which should be in stock at least |
||
730 | * |
||
731 | * @return self |
||
732 | */ |
||
733 | public function setMinAmount(float $new_minamount): self |
||
734 | { |
||
735 | //Assert::natural($new_mininstock, 'The new minimum instock value must be positive! Got %s.'); |
||
736 | |||
737 | $this->minamount = $new_minamount; |
||
738 | |||
739 | return $this; |
||
740 | } |
||
741 | |||
742 | /** |
||
743 | * Set the comment. |
||
744 | * |
||
745 | * @param string $new_comment the new comment |
||
746 | * |
||
747 | * @return self |
||
748 | */ |
||
749 | public function setComment(string $new_comment): self |
||
750 | { |
||
751 | $this->comment = $new_comment; |
||
752 | |||
753 | return $this; |
||
754 | } |
||
755 | |||
756 | /** |
||
757 | * Set the "manual_order" attribute. |
||
758 | * |
||
759 | * @param bool $new_manual_order the new "manual_order" attribute |
||
760 | * @param int $new_order_quantity the new order quantity |
||
761 | * @param int|null $new_order_orderdetails_id * the ID of the new order orderdetails |
||
762 | * * or Zero for "no order orderdetails" |
||
763 | * * or NULL for automatic order orderdetails |
||
764 | * (if the part has exactly one orderdetails, |
||
765 | * set this orderdetails as order orderdetails. |
||
766 | * Otherwise, set "no order orderdetails") |
||
767 | * |
||
768 | * @return self |
||
769 | */ |
||
770 | public function setManualOrder(bool $new_manual_order, int $new_order_quantity = 1, ?Orderdetail $new_order_orderdetail = null): Part |
||
771 | { |
||
772 | //Assert::greaterThan($new_order_quantity, 0, 'The new order quantity must be greater zero. Got %s!'); |
||
773 | |||
774 | $this->manual_order = $new_manual_order; |
||
775 | |||
776 | //TODO; |
||
777 | $this->order_orderdetail = $new_order_orderdetail; |
||
778 | $this->order_quantity = $new_order_quantity; |
||
779 | |||
780 | return $this; |
||
781 | } |
||
782 | |||
783 | /** |
||
784 | * Set the category of this Part. |
||
785 | * |
||
786 | * Every part must have a valid category (in contrast to the |
||
787 | * attributes "footprint", "storelocation", ...)! |
||
788 | * |
||
789 | * @param Category $category The new category of this part |
||
790 | * |
||
791 | * @return self |
||
792 | */ |
||
793 | public function setCategory(Category $category): Part |
||
794 | { |
||
795 | $this->category = $category; |
||
796 | |||
797 | return $this; |
||
798 | } |
||
799 | |||
800 | /** |
||
801 | * Set the new Footprint of this Part. |
||
802 | * |
||
803 | * @param Footprint|null $new_footprint The new footprint of this part. Set to null, if this part should not have |
||
804 | * a footprint. |
||
805 | * |
||
806 | * @return self |
||
807 | */ |
||
808 | public function setFootprint(?Footprint $new_footprint): Part |
||
809 | { |
||
810 | $this->footprint = $new_footprint; |
||
811 | |||
812 | return $this; |
||
813 | } |
||
814 | |||
815 | /** |
||
816 | * Sets the new manufacturer of this part. |
||
817 | * |
||
818 | * @param Manufacturer|null $new_manufacturer The new Manufacturer of this part. Set to null, if this part should |
||
819 | * not have a manufacturer. |
||
820 | * |
||
821 | * @return Part |
||
822 | */ |
||
823 | public function setManufacturer(?Manufacturer $new_manufacturer): self |
||
828 | } |
||
829 | |||
830 | /** |
||
831 | * Set the favorite status for this part. |
||
832 | * |
||
833 | * @param $new_favorite_status bool The new favorite status, that should be applied on this part. |
||
834 | * Set this to true, when the part should be a favorite. |
||
835 | * |
||
836 | * @return self |
||
837 | */ |
||
838 | public function setFavorite(bool $new_favorite_status): self |
||
843 | } |
||
844 | |||
845 | /** |
||
846 | * Sets the URL to the manufacturer site about this Part. Set to "" if this part should use the automatically URL based on its manufacturer. |
||
847 | * |
||
848 | * @param string $new_url The new url |
||
849 | * |
||
850 | * @return self |
||
851 | */ |
||
852 | public function setManufacturerProductURL(string $new_url): self |
||
853 | { |
||
854 | $this->manufacturer_product_url = $new_url; |
||
855 | |||
856 | return $this; |
||
857 | } |
||
858 | } |
||
859 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..