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\Customer\Manager\Address\Standard |
||
|
|||
22 | { |
||
23 | private $searchConfig = array( |
||
24 | 'customer.address.id' => array( |
||
25 | 'label' => 'Customer address ID', |
||
26 | 'code' => 'customer.address.id', |
||
27 | 'internalcode' => 'lvuad."id"', |
||
28 | 'internaldeps' => array( 'LEFT JOIN "users_address" AS lvuad ON ( lvu."id" = lvuad."parentid" )' ), |
||
29 | 'type' => 'integer', |
||
30 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT, |
||
31 | 'public' => false, |
||
32 | ), |
||
33 | // customer.siteid is only for informational purpuse, not for filtering |
||
34 | 'customer.address.refid' => array( |
||
35 | 'label' => 'Customer address parent ID', |
||
36 | 'code' => 'customer.address.parentid', |
||
37 | 'internalcode' => 'lvuad."parentid"', |
||
38 | 'type' => 'integer', |
||
39 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
40 | 'public' => false, |
||
41 | ), |
||
42 | 'customer.address.company'=> array( |
||
43 | 'label' => 'Customer address company', |
||
44 | 'code' => 'customer.address.company', |
||
45 | 'internalcode' => 'lvuad."company"', |
||
46 | 'type' => 'string', |
||
47 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
48 | ), |
||
49 | 'customer.address.vatid'=> array( |
||
50 | 'label' => 'Customer address VAT ID', |
||
51 | 'code' => 'customer.address.vatid', |
||
52 | 'internalcode' => 'lvuad."vatid"', |
||
53 | 'type' => 'string', |
||
54 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
55 | ), |
||
56 | 'customer.address.salutation' => array( |
||
57 | 'label' => 'Customer address salutation', |
||
58 | 'code' => 'customer.address.salutation', |
||
59 | 'internalcode' => 'lvuad."salutation"', |
||
60 | 'type' => 'integer', |
||
61 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
62 | ), |
||
63 | 'customer.address.title' => array( |
||
64 | 'label' => 'Customer address title', |
||
65 | 'code' => 'customer.address.title', |
||
66 | 'internalcode' => 'lvuad."title"', |
||
67 | 'type' => 'string', |
||
68 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
69 | ), |
||
70 | 'customer.address.firstname' => array( |
||
71 | 'label' => 'Customer address firstname', |
||
72 | 'code' => 'customer.address.firstname', |
||
73 | 'internalcode' => 'lvuad."firstname"', |
||
74 | 'type' => 'string', |
||
75 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
76 | ), |
||
77 | 'customer.address.lastname' => array( |
||
78 | 'label' => 'Customer address lastname', |
||
79 | 'code' => 'customer.address.lastname', |
||
80 | 'internalcode' => 'lvuad."lastname"', |
||
81 | 'type' => 'string', |
||
82 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
83 | ), |
||
84 | 'customer.address.address1' => array( |
||
85 | 'label' => 'Customer address address part one', |
||
86 | 'code' => 'customer.address.address1', |
||
87 | 'internalcode' => 'lvuad."address1"', |
||
88 | 'type' => 'string', |
||
89 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
90 | ), |
||
91 | 'customer.address.address2' => array( |
||
92 | 'label' => 'Customer address address part two', |
||
93 | 'code' => 'customer.address.address2', |
||
94 | 'internalcode' => 'lvuad."address2"', |
||
95 | 'type' => 'string', |
||
96 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
97 | ), |
||
98 | 'customer.address.address3' => array( |
||
99 | 'label' => 'Customer address address part three', |
||
100 | 'code' => 'customer.address.address3', |
||
101 | 'internalcode' => 'lvuad."address3"', |
||
102 | 'type' => 'string', |
||
103 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
104 | ), |
||
105 | 'customer.address.postal' => array( |
||
106 | 'label' => 'Customer address postal', |
||
107 | 'code' => 'customer.address.postal', |
||
108 | 'internalcode' => 'lvuad."postal"', |
||
109 | 'type' => 'string', |
||
110 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
111 | ), |
||
112 | 'customer.address.city' => array( |
||
113 | 'label' => 'Customer address city', |
||
114 | 'code' => 'customer.address.city', |
||
115 | 'internalcode' => 'lvuad."city"', |
||
116 | 'type' => 'string', |
||
117 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
118 | ), |
||
119 | 'customer.address.state' => array( |
||
120 | 'label' => 'Customer address state', |
||
121 | 'code' => 'customer.address.state', |
||
122 | 'internalcode' => 'lvuad."state"', |
||
123 | 'type' => 'string', |
||
124 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
125 | ), |
||
126 | 'customer.address.languageid' => array( |
||
127 | 'label' => 'Customer address language', |
||
128 | 'code' => 'customer.address.languageid', |
||
129 | 'internalcode' => 'lvuad."langid"', |
||
130 | 'type' => 'string', |
||
131 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
132 | ), |
||
133 | 'customer.address.countryid' => array( |
||
134 | 'label' => 'Customer address country', |
||
135 | 'code' => 'customer.address.countryid', |
||
136 | 'internalcode' => 'lvuad."countryid"', |
||
137 | 'type' => 'string', |
||
138 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
139 | ), |
||
140 | 'customer.address.telephone' => array( |
||
141 | 'label' => 'Customer address telephone', |
||
142 | 'code' => 'customer.address.telephone', |
||
143 | 'internalcode' => 'lvuad."telephone"', |
||
144 | 'type' => 'string', |
||
145 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
146 | ), |
||
147 | 'customer.address.email' => array( |
||
148 | 'label' => 'Customer address email', |
||
149 | 'code' => 'customer.address.email', |
||
150 | 'internalcode' => 'lvuad."email"', |
||
151 | 'type' => 'string', |
||
152 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
153 | ), |
||
154 | 'customer.address.telefax' => array( |
||
155 | 'label' => 'Customer address telefax', |
||
156 | 'code' => 'customer.address.telefax', |
||
157 | 'internalcode' => 'lvuad."telefax"', |
||
158 | 'type' => 'string', |
||
159 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
160 | ), |
||
161 | 'customer.address.website' => array( |
||
162 | 'label' => 'Customer address website', |
||
163 | 'code' => 'customer.address.website', |
||
164 | 'internalcode' => 'lvuad."website"', |
||
165 | 'type' => 'string', |
||
166 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
167 | ), |
||
168 | 'customer.address.longitude' => array( |
||
169 | 'label' => 'Customer address longitude', |
||
170 | 'code' => 'customer.address.longitude', |
||
171 | 'internalcode' => 'lvuad."longitude"', |
||
172 | 'type' => 'string', |
||
173 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
174 | ), |
||
175 | 'customer.address.latitude' => array( |
||
176 | 'label' => 'Customer address latitude', |
||
177 | 'code' => 'customer.address.latitude', |
||
178 | 'internalcode' => 'lvuad."latitude"', |
||
179 | 'type' => 'string', |
||
180 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
181 | ), |
||
182 | 'customer.address.flag' => array( |
||
183 | 'label' => 'Customer address flag', |
||
184 | 'code' => 'customer.address.flag', |
||
185 | 'internalcode' => 'lvuad."flag"', |
||
186 | 'type' => 'integer', |
||
187 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT, |
||
188 | ), |
||
189 | 'customer.address.position' => array( |
||
190 | 'label' => 'Customer address position', |
||
191 | 'code' => 'customer.address.position', |
||
192 | 'internalcode' => 'lvuad."pos"', |
||
193 | 'type' => 'integer', |
||
194 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT, |
||
195 | ), |
||
196 | 'customer.address.ctime'=> array( |
||
197 | 'label'=>'Customer address create date/time', |
||
198 | 'code'=>'customer.address.ctime', |
||
199 | 'internalcode'=>'lvuad."ctime"', |
||
200 | 'type'=> 'datetime', |
||
201 | 'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
202 | ), |
||
203 | 'customer.address.mtime'=> array( |
||
204 | 'label'=>'Customer address modification date/time', |
||
205 | 'code'=>'customer.address.mtime', |
||
206 | 'internalcode'=>'lvuad."mtime"', |
||
207 | 'type'=> 'datetime', |
||
208 | 'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
209 | ), |
||
210 | 'customer.address.editor'=> array( |
||
211 | 'label'=>'Customer address editor', |
||
212 | 'code'=>'customer.address.editor', |
||
213 | 'internalcode'=>'lvuad."editor"', |
||
214 | 'type'=> 'string', |
||
215 | 'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
||
216 | ), |
||
217 | ); |
||
218 | |||
219 | |||
220 | /** |
||
221 | * Removes old entries from the storage. |
||
222 | * |
||
223 | * @param array $siteids List of IDs for sites whose entries should be deleted |
||
224 | */ |
||
225 | View Code Duplication | public function cleanup( array $siteids ) |
|
234 | |||
235 | |||
236 | /** |
||
237 | * Returns the list attributes that can be used for searching. |
||
238 | * |
||
239 | * @param boolean $withsub Return also attributes of sub-managers if true |
||
240 | * @return array List of attribute items implementing \Aimeos\MW\Criteria\Attribute\Iface |
||
241 | */ |
||
242 | public function getSearchAttributes( $withsub = true ) |
||
248 | |||
249 | |||
250 | /** |
||
251 | * Returns a new manager for customer extensions |
||
252 | * |
||
253 | * @param string $manager Name of the sub manager type in lower case |
||
254 | * @param string|null $name Name of the implementation, will be from configuration (or Default) if null |
||
255 | * @return mixed Manager for different extensions, e.g stock, tags, locations, etc. |
||
256 | */ |
||
257 | public function getSubManager( $manager, $name = null ) |
||
261 | |||
262 | |||
263 | /** |
||
264 | * Returns the config path for retrieving the configuration values. |
||
265 | * |
||
266 | * @return string Configuration path (mshop/customer/manager/address/laravel/) |
||
267 | */ |
||
268 | protected function getConfigPath() |
||
272 | |||
273 | |||
274 | /** |
||
275 | * Returns the search configuration for searching items. |
||
276 | * |
||
277 | * @return array Associative list of search keys and search definitions |
||
278 | */ |
||
279 | protected function getSearchConfig() |
||
283 | } |
||
284 |