Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 9 | class OrderItemCollection extends \Doctrine\Common\Collections\ArrayCollection |
||
|
|
|||
| 10 | { |
||
| 11 | protected $type; |
||
| 12 | |||
| 13 | 124 | public function __construct($OrderItems, $type = null) |
|
| 19 | |||
| 20 | public function reduce(\Closure $func, $initial = null) |
||
| 24 | |||
| 25 | // 明細種別ごとに返すメソッド作る |
||
| 26 | 124 | public function getProductClasses() |
|
| 33 | |||
| 34 | public function getDeliveryFees() |
||
| 41 | |||
| 42 | public function getCharges() |
||
| 49 | |||
| 50 | public function getDiscounts() |
||
| 57 | |||
| 58 | /** |
||
| 59 | * 同名の明細が存在するかどうか. |
||
| 60 | * |
||
| 61 | * TODO 暫定対応. 本来は明細種別でチェックする. |
||
| 62 | */ |
||
| 63 | View Code Duplication | public function hasProductByName($productName) |
|
| 72 | |||
| 73 | /** |
||
| 74 | * 指定した受注明細区分の明細が存在するかどうか |
||
| 75 | * @param OrderItemType $OrderItemType 受注区分 |
||
| 76 | * @return boolean |
||
| 77 | */ |
||
| 78 | View Code Duplication | public function hasItemByOrderItemType($OrderItemType) |
|
| 86 | |||
| 87 | public function getType() |
||
| 91 | } |
||
| 92 |