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 |
||
| 19 | class EbayEnterprise_GiftCard_Block_Sales_Order_Total extends Mage_Core_Block_Template |
||
|
1 ignored issue
–
show
|
|||
| 20 | { |
||
| 21 | const TOTAL_CODE = 'ebayenterprise_giftcard'; |
||
| 22 | const TOTAL_LABEL = 'EbayEnterprise_GiftCard_Order_Total_Label'; |
||
| 23 | |||
| 24 | /** @var EbayEnterprise_GiftCard_Model_Container */ |
||
| 25 | protected $giftcardContainer; |
||
| 26 | /** @var EbayEnterprise_GiftCard_Helper_Data */ |
||
| 27 | protected $helper; |
||
| 28 | |||
| 29 | View Code Duplication | public function __construct(array $args = []) |
|
| 40 | |||
| 41 | /** |
||
| 42 | * Enforce type checks on construct args array. |
||
| 43 | * |
||
| 44 | * @param EbayEnterprise_GiftCard_Model_Container |
||
| 45 | * @param EbayEnterprise_GiftCard_Helper_Data |
||
| 46 | * @return array |
||
| 47 | */ |
||
| 48 | protected function checkTypes( |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Fill in default values. |
||
| 57 | * |
||
| 58 | * @param array |
||
| 59 | * @param string |
||
| 60 | * @param mixed |
||
| 61 | * @return mixed |
||
| 62 | */ |
||
| 63 | protected function nullCoalesce(array $arr, $key, $default) |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Get the current order model. |
||
| 70 | * |
||
| 71 | * @return Mage_Sales_Model_Order |
||
| 72 | */ |
||
| 73 | public function getOrder() |
||
| 77 | |||
| 78 | /** |
||
| 79 | * Register gift card totals with the order totals block. |
||
| 80 | * |
||
| 81 | * @return self |
||
| 82 | */ |
||
| 83 | public function initTotals() |
||
| 95 | |||
| 96 | /** |
||
| 97 | * Get all gift cards redeemed for the order. |
||
| 98 | * |
||
| 99 | * @return SPLObjectStorage |
||
| 100 | */ |
||
| 101 | public function getGiftCards() |
||
| 105 | |||
| 106 | /** |
||
| 107 | * Get the label to use for a gift card in the totals. |
||
| 108 | * |
||
| 109 | * @param EbayEnterprise_GiftCard_Model_Giftcard |
||
| 110 | * @return string |
||
| 111 | */ |
||
| 112 | public function getCardLabel(EbayEnterprise_GiftCard_Model_Giftcard $card) |
||
| 116 | |||
| 117 | /** |
||
| 118 | * Get the value of the gift card to display in the totals. |
||
| 119 | * |
||
| 120 | * @param EbayEnterprise_GiftCard_Model_Giftcard |
||
| 121 | * @return string |
||
| 122 | */ |
||
| 123 | public function getCardValue(EbayEnterprise_GiftCard_Model_Giftcard $card) |
||
| 127 | |||
| 128 | /** |
||
| 129 | * Attributes to add to the html element wrapping the total's label. |
||
| 130 | * |
||
| 131 | * @return string |
||
| 132 | */ |
||
| 133 | public function getLabelProperties() |
||
| 137 | |||
| 138 | /** |
||
| 139 | * Attributes to add to the html element wrapping the total's value. |
||
| 140 | * |
||
| 141 | * @return string |
||
| 142 | */ |
||
| 143 | public function getValueProperties() |
||
| 147 | } |
||
| 148 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.