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 |
||
22 | class Nexcessnet_Turpentine_Model_Observer_Varnish extends Varien_Event_Observer { |
||
|
|||
23 | /** |
||
24 | * Check sentinel flags and set headers/cookies as needed |
||
25 | * |
||
26 | * Events: http_response_send_before |
||
27 | * |
||
28 | * @param mixed $eventObject |
||
29 | * @return null |
||
30 | */ |
||
31 | View Code Duplication | public function setCacheFlagHeader($eventObject) { |
|
43 | |||
44 | /** |
||
45 | * Add a rewrite for catalog/product_list_toolbar if config option enabled |
||
46 | * |
||
47 | * @param Varien_Object $eventObject |
||
48 | * @return null |
||
49 | */ |
||
50 | public function addProductListToolbarRewrite($eventObject) { |
||
57 | |||
58 | /** |
||
59 | * Turpentine sets the fake cookie 'frontend=crawler-session' when a crawler is detected. |
||
60 | * This causes lock problems with Cm_RedisSession, because all crawler hits are requesting the same session lock. |
||
61 | * Cm_RedisSession provides the define CM_REDISSESSION_LOCKING_ENABLED to overrule if locking should be enabled. |
||
62 | * |
||
63 | * @param $eventObject |
||
64 | * @return null |
||
65 | */ |
||
66 | public function fixCmRedisSessionLocks($eventObject) { |
||
73 | |||
74 | /** |
||
75 | * Re-apply and save Varnish configuration on config change |
||
76 | * |
||
77 | * @param mixed $eventObject |
||
78 | * @return null |
||
79 | */ |
||
80 | public function adminSystemConfigChangedSection($eventObject) { |
||
111 | } |
||
112 |
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.