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 |
||
20 | class Laravel |
||
21 | extends \Aimeos\MShop\Common\Manager\Property\Base |
||
22 | implements \Aimeos\MShop\Customer\Manager\Property\Iface |
||
23 | { |
||
24 | private $searchConfig = array( |
||
25 | 'customer.property.id' => array( |
||
26 | 'code' => 'customer.property.id', |
||
27 | 'internalcode' => 'lvupr."id"', |
||
28 | 'internaldeps'=>array( 'LEFT JOIN "users_property" AS lvupr ON ( lvupr."parentid" = fos."id" )' ), |
||
29 | 'label' => 'Property ID', |
||
30 | 'type' => 'integer', |
||
31 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT, |
||
32 | 'public' => false, |
||
33 | ), |
||
34 | 'customer.property.parentid' => array( |
||
35 | 'code' => 'customer.property.parentid', |
||
36 | 'internalcode' => 'lvupr."parentid"', |
||
37 | 'label' => 'Property parent ID', |
||
38 | 'type' => 'integer', |
||
39 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT, |
||
40 | 'public' => false, |
||
41 | ), |
||
42 | 'customer.property.siteid' => array( |
||
43 | 'code' => 'customer.property.siteid', |
||
44 | 'internalcode' => 'lvupr."siteid"', |
||
45 | 'label' => 'Property site ID', |
||
46 | 'type' => 'integer', |
||
47 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT, |
||
48 | 'public' => false, |
||
49 | ), |
||
50 | 'customer.property.typeid' => array( |
||
51 | 'code' => 'customer.property.typeid', |
||
52 | 'internalcode' => 'lvupr."typeid"', |
||
53 | 'label' => 'Property type ID', |
||
54 | 'type' => 'integer', |
||
55 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT, |
||
56 | 'public' => false, |
||
57 | ), |
||
58 | 'customer.property.value' => array( |
||
59 | 'code' => 'customer.property.value', |
||
60 | 'internalcode' => 'lvupr."value"', |
||
61 | 'label' => 'Property value', |
||
62 | 'type' => 'string', |
||
63 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
64 | ), |
||
65 | 'customer.property.languageid' => array( |
||
66 | 'code' => 'customer.property.languageid', |
||
67 | 'internalcode' => 'lvupr."langid"', |
||
68 | 'label' => 'Property language ID', |
||
69 | 'type' => 'string', |
||
70 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
71 | ), |
||
72 | 'customer.property.ctime' => array( |
||
73 | 'code' => 'customer.property.ctime', |
||
74 | 'internalcode' => 'lvupr."ctime"', |
||
75 | 'label' => 'Property create date/time', |
||
76 | 'type' => 'datetime', |
||
77 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
78 | 'public' => false, |
||
79 | ), |
||
80 | 'customer.property.mtime' => array( |
||
81 | 'code' => 'customer.property.mtime', |
||
82 | 'internalcode' => 'lvupr."mtime"', |
||
83 | 'label' => 'Property modify date', |
||
84 | 'type' => 'datetime', |
||
85 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
86 | 'public' => false, |
||
87 | ), |
||
88 | 'customer.property.editor' => array( |
||
89 | 'code' => 'customer.property.editor', |
||
90 | 'internalcode' => 'lvupr."editor"', |
||
91 | 'label' => 'Property editor', |
||
92 | 'type' => 'string', |
||
93 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
94 | 'public' => false, |
||
95 | ), |
||
96 | ); |
||
97 | |||
98 | |||
99 | /** |
||
100 | * Initializes the object. |
||
101 | * |
||
102 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
||
103 | */ |
||
104 | public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
||
109 | |||
110 | |||
111 | /** |
||
112 | * Removes old entries from the storage. |
||
113 | * |
||
114 | * @param integer[] $siteids List of IDs for sites whose entries should be deleted |
||
115 | */ |
||
116 | View Code Duplication | public function cleanup( array $siteids ) |
|
125 | |||
126 | |||
127 | /** |
||
128 | * Returns the available manager types |
||
129 | * |
||
130 | * @param boolean $withsub Return also the resource type of sub-managers if true |
||
131 | * @return array Type of the manager and submanagers, subtypes are separated by slashes |
||
132 | */ |
||
133 | public function getResourceType( $withsub = true ) |
||
139 | |||
140 | |||
141 | /** |
||
142 | * Returns the attributes that can be used for searching. |
||
143 | * |
||
144 | * @param boolean $withsub Return also attributes of sub-managers if true |
||
145 | * @return array Returns a list of attribtes implementing \Aimeos\MW\Criteria\Attribute\Iface |
||
146 | */ |
||
147 | public function getSearchAttributes( $withsub = true ) |
||
153 | |||
154 | |||
155 | /** |
||
156 | * Returns a new manager for customer extensions |
||
157 | * |
||
158 | * @param string $manager Name of the sub manager type in lower case |
||
159 | * @param string|null $name Name of the implementation, will be from |
||
160 | * configuration (or Default) if null |
||
161 | * @return \Aimeos\MShop\Common\Manager\Iface Manager for different extensions, e.g property types, property lists etc. |
||
162 | */ |
||
163 | public function getSubManager( $manager, $name = null ) |
||
167 | |||
168 | |||
169 | /** |
||
170 | * Returns the config path for retrieving the configuration values. |
||
171 | * |
||
172 | * @return string Configuration path |
||
173 | */ |
||
174 | protected function getConfigPath() |
||
178 | |||
179 | |||
180 | /** |
||
181 | * Returns the search configuration for searching items. |
||
182 | * |
||
183 | * @return array Associative list of search keys and search definitions |
||
184 | */ |
||
185 | protected function getSearchConfig() |
||
189 | } |
||
190 |