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 |
||
| 16 | class EbayEnterprise_Eb2cGiftwrap_Model_Observers |
||
| 17 | { |
||
| 18 | /** @var EbayEnterprise_Eb2cGiftwrap_Model_Order_Create_Gifting */ |
||
| 19 | protected $orderGifting; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param array |
||
| 23 | */ |
||
| 24 | public function __construct($args = []) |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @param EbayEnterprise_Eb2cGiftwrap_Model_Order_Create_Gifting |
||
| 35 | * @return array |
||
| 36 | */ |
||
| 37 | protected function checkTypes( |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @param array |
||
| 45 | * @param string|int |
||
| 46 | * @param mixed |
||
| 47 | * @return mixed |
||
| 48 | */ |
||
| 49 | protected function nullCoalesce(array $arr, $key, $default) |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Listen to the 'ebayenterprise_feed_dom_loaded' event |
||
| 56 | * @see EbayEnterprise_Catalog_Model_Feed_Abstract::processFile |
||
| 57 | * process a dom document |
||
| 58 | * @param Varien_Event_Observer $observer |
||
| 59 | * @return self |
||
| 60 | */ |
||
| 61 | View Code Duplication | public function processDom(Varien_Event_Observer $observer) |
|
| 81 | |||
| 82 | /** |
||
| 83 | * Add order level gifting to the payload for order create requests. |
||
| 84 | * |
||
| 85 | * @param Varien_Event_Observer |
||
| 86 | */ |
||
| 87 | public function handleEbayEnterpriseOrderCreateShipGroup(Varien_Event_Observer $observer) |
||
| 110 | |||
| 111 | /** |
||
| 112 | * Add item level gifting to the payload for order create requests. |
||
| 113 | * |
||
| 114 | * @param Varien_Event_Observer |
||
| 115 | */ |
||
| 116 | public function handleEbayEnterpriseOrderCreateItem(Varien_Event_Observer $observer) |
||
| 124 | } |
||
| 125 |