Complex classes like OrderItem 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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
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 OrderItem, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
32 | class OrderItem extends \Eccube\Entity\AbstractEntity implements ItemInterface |
||
33 | { |
||
34 | use PointRateTrait; |
||
35 | |||
36 | /** |
||
37 | * Get price IncTax |
||
38 | * |
||
39 | * @return string |
||
40 | */ |
||
41 | public function getPriceIncTax() |
||
50 | |||
51 | /** |
||
52 | * @return integer |
||
53 | */ |
||
54 | public function getTotalPrice() |
||
58 | |||
59 | /** |
||
60 | * @return integer |
||
61 | */ |
||
62 | public function getOrderItemTypeId() |
||
70 | |||
71 | /** |
||
72 | * 商品明細かどうか. |
||
73 | * |
||
74 | * @return boolean 商品明細の場合 true |
||
75 | */ |
||
76 | public function isProduct() |
||
80 | |||
81 | /** |
||
82 | * 送料明細かどうか. |
||
83 | * |
||
84 | * @return boolean 送料明細の場合 true |
||
85 | */ |
||
86 | public function isDeliveryFee() |
||
90 | |||
91 | /** |
||
92 | * 手数料明細かどうか. |
||
93 | * |
||
94 | * @return boolean 手数料明細の場合 true |
||
95 | */ |
||
96 | public function isCharge() |
||
100 | |||
101 | /** |
||
102 | * 値引き明細かどうか. |
||
103 | * |
||
104 | * @return boolean 値引き明細の場合 true |
||
105 | */ |
||
106 | public function isDiscount() |
||
110 | |||
111 | /** |
||
112 | * 税額明細かどうか. |
||
113 | * |
||
114 | * @return boolean 税額明細の場合 true |
||
115 | */ |
||
116 | public function isTax() |
||
120 | |||
121 | /** |
||
122 | * ポイント明細かどうか. |
||
123 | * |
||
124 | * @return boolean ポイント明細の場合 true |
||
125 | */ |
||
126 | public function isPoint() |
||
130 | |||
131 | /** |
||
132 | * @var integer |
||
133 | * |
||
134 | * @ORM\Column(name="id", type="integer", options={"unsigned":true}) |
||
135 | * @ORM\Id |
||
136 | * @ORM\GeneratedValue(strategy="IDENTITY") |
||
137 | */ |
||
138 | private $id; |
||
139 | |||
140 | /** |
||
141 | * @var string |
||
142 | * |
||
143 | * @ORM\Column(name="product_name", type="string", length=255) |
||
144 | */ |
||
145 | private $product_name; |
||
146 | |||
147 | /** |
||
148 | * @var string|null |
||
149 | * |
||
150 | * @ORM\Column(name="product_code", type="string", length=255, nullable=true) |
||
151 | */ |
||
152 | private $product_code; |
||
153 | |||
154 | /** |
||
155 | * @var string|null |
||
156 | * |
||
157 | * @ORM\Column(name="class_name1", type="string", length=255, nullable=true) |
||
158 | */ |
||
159 | private $class_name1; |
||
160 | |||
161 | /** |
||
162 | * @var string|null |
||
163 | * |
||
164 | * @ORM\Column(name="class_name2", type="string", length=255, nullable=true) |
||
165 | */ |
||
166 | private $class_name2; |
||
167 | |||
168 | /** |
||
169 | * @var string|null |
||
170 | * |
||
171 | * @ORM\Column(name="class_category_name1", type="string", length=255, nullable=true) |
||
172 | */ |
||
173 | private $class_category_name1; |
||
174 | |||
175 | /** |
||
176 | * @var string|null |
||
177 | * |
||
178 | * @ORM\Column(name="class_category_name2", type="string", length=255, nullable=true) |
||
179 | */ |
||
180 | private $class_category_name2; |
||
181 | |||
182 | /** |
||
183 | * @var string |
||
184 | * |
||
185 | * @ORM\Column(name="price", type="decimal", precision=12, scale=2, options={"default":0}) |
||
186 | */ |
||
187 | private $price = 0; |
||
188 | |||
189 | /** |
||
190 | * @var string |
||
191 | * |
||
192 | * @ORM\Column(name="quantity", type="decimal", precision=10, scale=0, options={"default":0}) |
||
193 | */ |
||
194 | private $quantity = 0; |
||
195 | |||
196 | /** |
||
197 | * @var string |
||
198 | * |
||
199 | * @ORM\Column(name="tax", type="decimal", precision=10, scale=0, options={"default":0}) |
||
200 | */ |
||
201 | private $tax = 0; |
||
202 | |||
203 | /** |
||
204 | * @var string |
||
205 | * |
||
206 | * @ORM\Column(name="tax_rate", type="decimal", precision=10, scale=0, options={"unsigned":true,"default":0}) |
||
207 | */ |
||
208 | private $tax_rate = 0; |
||
209 | |||
210 | /** |
||
211 | * @var string |
||
212 | * |
||
213 | * @ORM\Column(name="tax_adjust", type="decimal", precision=10, scale=0, options={"unsigned":true,"default":0}) |
||
214 | */ |
||
215 | private $tax_adjust = 0; |
||
216 | |||
217 | /** |
||
218 | * @var int|null |
||
219 | * @deprecated 税率設定は受注作成時に決定するため廃止予定 |
||
220 | * |
||
221 | * @ORM\Column(name="tax_rule_id", type="smallint", nullable=true, options={"unsigned":true}) |
||
222 | */ |
||
223 | private $tax_rule_id; |
||
224 | |||
225 | /** |
||
226 | * @var string|null |
||
227 | * |
||
228 | * @ORM\Column(name="currency_code", type="string", nullable=true) |
||
229 | */ |
||
230 | private $currency_code; |
||
231 | |||
232 | /** |
||
233 | * @var string|null |
||
234 | * |
||
235 | * @ORM\Column(name="processor_name", type="string", nullable=true) |
||
236 | */ |
||
237 | private $processor_name; |
||
238 | |||
239 | /** |
||
240 | * @var \Eccube\Entity\Order |
||
241 | * |
||
242 | * @ORM\ManyToOne(targetEntity="Eccube\Entity\Order", inversedBy="OrderItems") |
||
243 | * @ORM\JoinColumns({ |
||
244 | * @ORM\JoinColumn(name="order_id", referencedColumnName="id") |
||
245 | * }) |
||
246 | */ |
||
247 | private $Order; |
||
248 | |||
249 | /** |
||
250 | * @var \Eccube\Entity\Product |
||
251 | * |
||
252 | * @ORM\ManyToOne(targetEntity="Eccube\Entity\Product") |
||
253 | * @ORM\JoinColumns({ |
||
254 | * @ORM\JoinColumn(name="product_id", referencedColumnName="id") |
||
255 | * }) |
||
256 | */ |
||
257 | private $Product; |
||
258 | |||
259 | /** |
||
260 | * @var \Eccube\Entity\ProductClass |
||
261 | * |
||
262 | * @ORM\ManyToOne(targetEntity="Eccube\Entity\ProductClass") |
||
263 | * @ORM\JoinColumns({ |
||
264 | * @ORM\JoinColumn(name="product_class_id", referencedColumnName="id") |
||
265 | * }) |
||
266 | */ |
||
267 | private $ProductClass; |
||
268 | |||
269 | /** |
||
270 | * @var \Eccube\Entity\Shipping |
||
271 | * |
||
272 | * @ORM\ManyToOne(targetEntity="Eccube\Entity\Shipping", inversedBy="OrderItems") |
||
273 | * @ORM\JoinColumns({ |
||
274 | * @ORM\JoinColumn(name="shipping_id", referencedColumnName="id") |
||
275 | * }) |
||
276 | */ |
||
277 | private $Shipping; |
||
278 | |||
279 | /** |
||
280 | * @var \Eccube\Entity\Master\RoundingType |
||
281 | * |
||
282 | * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\RoundingType") |
||
283 | * @ORM\JoinColumns({ |
||
284 | * @ORM\JoinColumn(name="rounding_type_id", referencedColumnName="id") |
||
285 | * }) |
||
286 | */ |
||
287 | private $RoundingType; |
||
288 | |||
289 | /** |
||
290 | * @var \Eccube\Entity\Master\TaxType |
||
291 | * |
||
292 | * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\TaxType") |
||
293 | * @ORM\JoinColumns({ |
||
294 | * @ORM\JoinColumn(name="tax_type_id", referencedColumnName="id") |
||
295 | * }) |
||
296 | */ |
||
297 | private $TaxType; |
||
298 | |||
299 | /** |
||
300 | * @var \Eccube\Entity\Master\TaxDisplayType |
||
301 | * |
||
302 | * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\TaxDisplayType") |
||
303 | * @ORM\JoinColumns({ |
||
304 | * @ORM\JoinColumn(name="tax_display_type_id", referencedColumnName="id") |
||
305 | * }) |
||
306 | */ |
||
307 | private $TaxDisplayType; |
||
308 | |||
309 | /** |
||
310 | * @var \Eccube\Entity\Master\OrderItemType |
||
311 | * |
||
312 | * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\OrderItemType") |
||
313 | * @ORM\JoinColumns({ |
||
314 | * @ORM\JoinColumn(name="order_item_type_id", referencedColumnName="id") |
||
315 | * }) |
||
316 | */ |
||
317 | private $OrderItemType; |
||
318 | |||
319 | /** |
||
320 | * Get id. |
||
321 | * |
||
322 | * @return int |
||
323 | */ |
||
324 | public function getId() |
||
328 | |||
329 | /** |
||
330 | * Set productName. |
||
331 | * |
||
332 | * @param string $productName |
||
333 | * |
||
334 | * @return OrderItem |
||
335 | */ |
||
336 | public function setProductName($productName) |
||
342 | |||
343 | /** |
||
344 | * Get productName. |
||
345 | * |
||
346 | * @return string |
||
347 | */ |
||
348 | public function getProductName() |
||
352 | |||
353 | /** |
||
354 | * Set productCode. |
||
355 | * |
||
356 | * @param string|null $productCode |
||
357 | * |
||
358 | * @return OrderItem |
||
359 | */ |
||
360 | public function setProductCode($productCode = null) |
||
366 | |||
367 | /** |
||
368 | * Get productCode. |
||
369 | * |
||
370 | * @return string|null |
||
371 | */ |
||
372 | public function getProductCode() |
||
376 | |||
377 | /** |
||
378 | * Set className1. |
||
379 | * |
||
380 | * @param string|null $className1 |
||
381 | * |
||
382 | * @return OrderItem |
||
383 | */ |
||
384 | public function setClassName1($className1 = null) |
||
390 | |||
391 | /** |
||
392 | * Get className1. |
||
393 | * |
||
394 | * @return string|null |
||
395 | */ |
||
396 | public function getClassName1() |
||
400 | |||
401 | /** |
||
402 | * Set className2. |
||
403 | * |
||
404 | * @param string|null $className2 |
||
405 | * |
||
406 | * @return OrderItem |
||
407 | */ |
||
408 | public function setClassName2($className2 = null) |
||
414 | |||
415 | /** |
||
416 | * Get className2. |
||
417 | * |
||
418 | * @return string|null |
||
419 | */ |
||
420 | public function getClassName2() |
||
424 | |||
425 | /** |
||
426 | * Set classCategoryName1. |
||
427 | * |
||
428 | * @param string|null $classCategoryName1 |
||
429 | * |
||
430 | * @return OrderItem |
||
431 | */ |
||
432 | public function setClassCategoryName1($classCategoryName1 = null) |
||
438 | |||
439 | /** |
||
440 | * Get classCategoryName1. |
||
441 | * |
||
442 | * @return string|null |
||
443 | */ |
||
444 | public function getClassCategoryName1() |
||
448 | |||
449 | /** |
||
450 | * Set classCategoryName2. |
||
451 | * |
||
452 | * @param string|null $classCategoryName2 |
||
453 | * |
||
454 | * @return OrderItem |
||
455 | */ |
||
456 | public function setClassCategoryName2($classCategoryName2 = null) |
||
462 | |||
463 | /** |
||
464 | * Get classCategoryName2. |
||
465 | * |
||
466 | * @return string|null |
||
467 | */ |
||
468 | public function getClassCategoryName2() |
||
472 | |||
473 | /** |
||
474 | * Set price. |
||
475 | * |
||
476 | * @param string $price |
||
477 | * |
||
478 | * @return OrderItem |
||
479 | */ |
||
480 | public function setPrice($price) |
||
486 | |||
487 | /** |
||
488 | * Get price. |
||
489 | * |
||
490 | * @return string |
||
491 | */ |
||
492 | public function getPrice() |
||
496 | |||
497 | /** |
||
498 | * Set quantity. |
||
499 | * |
||
500 | * @param string $quantity |
||
501 | * |
||
502 | * @return OrderItem |
||
503 | */ |
||
504 | public function setQuantity($quantity) |
||
510 | |||
511 | /** |
||
512 | * Get quantity. |
||
513 | * |
||
514 | * @return string |
||
515 | */ |
||
516 | public function getQuantity() |
||
520 | |||
521 | /** |
||
522 | * @return string |
||
523 | */ |
||
524 | public function getTax() |
||
528 | |||
529 | /** |
||
530 | * @param string $tax |
||
531 | * |
||
532 | * @return $this |
||
533 | */ |
||
534 | public function setTax($tax) |
||
540 | |||
541 | /** |
||
542 | * Set taxRate. |
||
543 | * |
||
544 | * @param string $taxRate |
||
545 | * |
||
546 | * @return OrderItem |
||
547 | */ |
||
548 | public function setTaxRate($taxRate) |
||
554 | |||
555 | /** |
||
556 | * Get taxRate. |
||
557 | * |
||
558 | * @return string |
||
559 | */ |
||
560 | public function getTaxRate() |
||
564 | |||
565 | /** |
||
566 | * Set taxAdjust. |
||
567 | * |
||
568 | * @param string $tax_adjust |
||
569 | * |
||
570 | * @return OrderItem |
||
571 | */ |
||
572 | public function setTaxAdjust($tax_adjust) |
||
578 | |||
579 | /** |
||
580 | * Get taxAdjust. |
||
581 | * |
||
582 | * @return string |
||
583 | */ |
||
584 | public function getTaxAdjust() |
||
588 | |||
589 | /** |
||
590 | * Set taxRuleId. |
||
591 | * @deprecated 税率設定は受注作成時に決定するため廃止予定 |
||
592 | * |
||
593 | * @param int|null $taxRuleId |
||
594 | * |
||
595 | * @return OrderItem |
||
596 | */ |
||
597 | public function setTaxRuleId($taxRuleId = null) |
||
603 | |||
604 | /** |
||
605 | * Get taxRuleId. |
||
606 | * @deprecated 税率設定は受注作成時に決定するため廃止予定 |
||
607 | * |
||
608 | * @return int|null |
||
609 | */ |
||
610 | public function getTaxRuleId() |
||
614 | |||
615 | /** |
||
616 | * Get currencyCode. |
||
617 | * |
||
618 | * @return string |
||
619 | */ |
||
620 | public function getCurrencyCode() |
||
624 | |||
625 | /** |
||
626 | * Set currencyCode. |
||
627 | * |
||
628 | * @param string|null $currencyCode |
||
629 | * |
||
630 | * @return OrderItem |
||
631 | */ |
||
632 | public function setCurrencyCode($currencyCode = null) |
||
638 | |||
639 | /** |
||
640 | * Get processorName. |
||
641 | * |
||
642 | * @return string |
||
643 | */ |
||
644 | public function getProcessorName() |
||
648 | |||
649 | /** |
||
650 | * Set processorName. |
||
651 | * |
||
652 | * @param string|null $processorName |
||
653 | * |
||
654 | * @return $this |
||
655 | */ |
||
656 | public function setProcessorName($processorName = null) |
||
662 | |||
663 | /** |
||
664 | * Set order. |
||
665 | * |
||
666 | * @param \Eccube\Entity\Order|null $order |
||
667 | * |
||
668 | * @return OrderItem |
||
669 | */ |
||
670 | public function setOrder(\Eccube\Entity\Order $order = null) |
||
676 | |||
677 | /** |
||
678 | * Get order. |
||
679 | * |
||
680 | * @return \Eccube\Entity\Order|null |
||
681 | */ |
||
682 | public function getOrder() |
||
686 | |||
687 | public function getOrderId() |
||
695 | |||
696 | /** |
||
697 | * Set product. |
||
698 | * |
||
699 | * @param \Eccube\Entity\Product|null $product |
||
700 | * |
||
701 | * @return OrderItem |
||
702 | */ |
||
703 | public function setProduct(\Eccube\Entity\Product $product = null) |
||
709 | |||
710 | /** |
||
711 | * Get product. |
||
712 | * |
||
713 | * @return \Eccube\Entity\Product|null |
||
714 | */ |
||
715 | public function getProduct() |
||
719 | |||
720 | /** |
||
721 | * Set productClass. |
||
722 | * |
||
723 | * @param \Eccube\Entity\ProductClass|null $productClass |
||
724 | * |
||
725 | * @return OrderItem |
||
726 | */ |
||
727 | public function setProductClass(\Eccube\Entity\ProductClass $productClass = null) |
||
733 | |||
734 | /** |
||
735 | * Get productClass. |
||
736 | * |
||
737 | * @return \Eccube\Entity\ProductClass|null |
||
738 | */ |
||
739 | public function getProductClass() |
||
743 | |||
744 | /** |
||
745 | * Set shipping. |
||
746 | * |
||
747 | * @param \Eccube\Entity\Shipping|null $shipping |
||
748 | * |
||
749 | * @return OrderItem |
||
750 | */ |
||
751 | public function setShipping(\Eccube\Entity\Shipping $shipping = null) |
||
757 | |||
758 | /** |
||
759 | * Get shipping. |
||
760 | * |
||
761 | * @return \Eccube\Entity\Shipping|null |
||
762 | */ |
||
763 | public function getShipping() |
||
767 | |||
768 | /** |
||
769 | * @return RoundingType |
||
770 | */ |
||
771 | public function getRoundingType() |
||
775 | |||
776 | /** |
||
777 | * @param RoundingType $RoundingType |
||
778 | */ |
||
779 | public function setRoundingType(RoundingType $RoundingType = null) |
||
785 | |||
786 | /** |
||
787 | * Set taxType |
||
788 | * |
||
789 | * @param \Eccube\Entity\Master\TaxType $taxType |
||
790 | * |
||
791 | * @return OrderItem |
||
792 | */ |
||
793 | public function setTaxType(\Eccube\Entity\Master\TaxType $taxType = null) |
||
799 | |||
800 | /** |
||
801 | * Get taxType |
||
802 | * |
||
803 | * @return \Eccube\Entity\Master\TaxType |
||
804 | */ |
||
805 | public function getTaxType() |
||
809 | |||
810 | /** |
||
811 | * Set taxDisplayType |
||
812 | * |
||
813 | * @param \Eccube\Entity\Master\TaxDisplayType $taxDisplayType |
||
814 | * |
||
815 | * @return OrderItem |
||
816 | */ |
||
817 | public function setTaxDisplayType(\Eccube\Entity\Master\TaxDisplayType $taxDisplayType = null) |
||
823 | |||
824 | /** |
||
825 | * Get taxDisplayType |
||
826 | * |
||
827 | * @return \Eccube\Entity\Master\TaxDisplayType |
||
828 | */ |
||
829 | public function getTaxDisplayType() |
||
833 | |||
834 | /** |
||
835 | * Set orderItemType |
||
836 | * |
||
837 | * @param \Eccube\Entity\Master\OrderItemType $orderItemType |
||
838 | * |
||
839 | * @return OrderItem |
||
840 | */ |
||
841 | public function setOrderItemType(\Eccube\Entity\Master\OrderItemType $orderItemType = null) |
||
847 | |||
848 | /** |
||
849 | * Get orderItemType |
||
850 | * |
||
851 | * @return \Eccube\Entity\Master\OrderItemType |
||
852 | */ |
||
853 | public function getOrderItemType() |
||
857 | } |
||
858 | } |
||
859 |
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.