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_Tax_Block_Sales_Order_Tax extends Mage_Core_Block_Abstract |
||
1 ignored issue
–
show
|
|||
20 | { |
||
21 | const TAX_LABEL = 'EbayEnterprise_Tax_Order_Total_Tax_Title'; |
||
22 | const TOTAL_CODE = 'ebayenterprise_tax'; |
||
23 | |||
24 | /** @var EbayEnterprise_Tax_Model_Collector */ |
||
25 | protected $taxCollector; |
||
26 | /** @var EbayEnterprise_Tax_Helper_Data */ |
||
27 | protected $helper; |
||
28 | |||
29 | /** |
||
30 | * @param array May contain: |
||
31 | * - tax_collector => EbayEnterprise_Tax_Model_Collector |
||
32 | */ |
||
33 | View Code Duplication | public function __construct(array $args = []) |
|
44 | |||
45 | /** |
||
46 | * Enforce type checks on construct args array. |
||
47 | * |
||
48 | * @param EbayEnterprise_Tax_Model_Collector |
||
49 | * @param EbayEnterprise_Tax_Helper_Data |
||
50 | * @return array |
||
51 | */ |
||
52 | protected function checkTypes( |
||
58 | |||
59 | /** |
||
60 | * Fill in default values. |
||
61 | * |
||
62 | * @param array |
||
63 | * @param string |
||
64 | * @param mixed |
||
65 | * @return mixed |
||
66 | */ |
||
67 | protected function nullCoalesce(array $arr, $key, $default) |
||
71 | |||
72 | /** |
||
73 | * Add totals for collected taxes to the parent block. Totals added to the |
||
74 | * parent will be displayed with order totals. |
||
75 | * |
||
76 | * @return self |
||
77 | */ |
||
78 | public function initTotals() |
||
95 | |||
96 | /** |
||
97 | * Total all taxes associated with the current order. |
||
98 | * |
||
99 | * @return float |
||
100 | */ |
||
101 | protected function totalTaxAmount() |
||
109 | } |
||
110 |
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.