Completed
Push — master ( ac66b3...ab3b6f )
by Aimeos
07:35 queued 01:23
created

Ezpublish   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 175
Duplicated Lines 5.14 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 7
c 1
b 0
f 1
lcom 1
cbo 0
dl 9
loc 175
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A cleanup() 9 9 2
A getSearchAttributes() 0 6 1
A getSubManager() 0 4 2
A getConfigPath() 0 4 1
A getSearchConfig() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

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
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2016
6
 * @package MShop
7
 * @subpackage Customer
8
 */
9
10
11
namespace Aimeos\MShop\Customer\Manager\Lists;
12
13
14
/**
15
 * ezPublish implementation of the customer list class
16
 *
17
 * @package MShop
18
 * @subpackage Customer
19
 */
20
class Ezpublish
21
	extends \Aimeos\MShop\Customer\Manager\Lists\Standard
22
	implements \Aimeos\MShop\Customer\Manager\Lists\Iface, \Aimeos\MShop\Common\Manager\Lists\Iface
23
{
24
	private $searchConfig = array(
25
		'customer.lists.id'=> array(
26
			'code'=>'customer.lists.id',
27
			'internalcode'=>'ezuli."id"',
28
			'internaldeps' => array( 'LEFT JOIN "ezuser_list" AS ezuli ON ( ezu."id" = ezuli."parentid" )' ),
29
			'label'=>'Customer list ID',
30
			'type'=> 'integer',
31
			'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_INT,
32
			'public' => false,
33
		),
34
		'customer.lists.siteid'=> array(
35
			'code'=>'customer.lists.siteid',
36
			'internalcode'=>'ezuli."siteid"',
37
			'label'=>'Customer list site ID',
38
			'type'=> 'integer',
39
			'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_INT,
40
			'public' => false,
41
		),
42
		'customer.lists.parentid'=> array(
43
			'code'=>'customer.lists.parentid',
44
			'internalcode'=>'ezuli."parentid"',
45
			'label'=>'Customer list parent ID',
46
			'type'=> 'integer',
47
			'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_INT,
48
			'public' => false,
49
		),
50
		'customer.lists.domain'=> array(
51
			'code'=>'customer.lists.domain',
52
			'internalcode'=>'ezuli."domain"',
53
			'label'=>'Customer list domain',
54
			'type'=> 'string',
55
			'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR,
56
		),
57
		'customer.lists.typeid' => array(
58
			'code'=>'customer.lists.typeid',
59
			'internalcode'=>'ezuli."typeid"',
60
			'label'=>'Customer list type ID',
61
			'type'=> 'integer',
62
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT,
63
			'public' => false,
64
		),
65
		'customer.lists.refid'=> array(
66
			'code'=>'customer.lists.refid',
67
			'internalcode'=>'ezuli."refid"',
68
			'label'=>'Customer list reference ID',
69
			'type'=> 'string',
70
			'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR,
71
		),
72
		'customer.lists.datestart' => array(
73
			'code'=>'customer.lists.datestart',
74
			'internalcode'=>'ezuli."start"',
75
			'label'=>'Customer list start date/time',
76
			'type'=> 'datetime',
77
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
78
		),
79
		'customer.lists.dateend' => array(
80
			'code'=>'customer.lists.dateend',
81
			'internalcode'=>'ezuli."end"',
82
			'label'=>'Customer list end date/time',
83
			'type'=> 'datetime',
84
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
85
		),
86
		'customer.lists.config' => array(
87
			'code'=>'customer.lists.config',
88
			'internalcode'=>'ezuli."config"',
89
			'label'=>'Customer list position',
90
			'type'=> 'string',
91
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
92
		),
93
		'customer.lists.position' => array(
94
			'code'=>'customer.lists.position',
95
			'internalcode'=>'ezuli."pos"',
96
			'label'=>'Customer list position',
97
			'type'=> 'integer',
98
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT,
99
		),
100
		'customer.lists.status' => array(
101
			'code'=>'customer.lists.status',
102
			'internalcode'=>'ezuli."status"',
103
			'label'=>'Customer list status',
104
			'type'=> 'integer',
105
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT,
106
		),
107
		'customer.lists.ctime'=> array(
108
			'code'=>'customer.lists.ctime',
109
			'internalcode'=>'ezuli."ctime"',
110
			'label'=>'Customer list create date/time',
111
			'type'=> 'datetime',
112
			'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR,
113
		),
114
		'customer.lists.mtime'=> array(
115
			'code'=>'customer.lists.mtime',
116
			'internalcode'=>'ezuli."mtime"',
117
			'label'=>'Customer list modification date/time',
118
			'type'=> 'datetime',
119
			'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR,
120
		),
121
		'customer.lists.editor'=> array(
122
			'code'=>'customer.lists.editor',
123
			'internalcode'=>'ezuli."editor"',
124
			'label'=>'Customer list editor',
125
			'type'=> 'string',
126
			'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR,
127
		),
128
	);
129
130
131
	/**
132
	 * Removes old entries from the storage.
133
	 *
134
	 * @param array $siteids List of IDs for sites whose entries should be deleted
135
	 */
136 View Code Duplication
	public function cleanup( array $siteids )
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
137
	{
138
		$path = 'mshop/customer/manager/lists/submanagers';
139
		foreach( $this->getContext()->getConfig()->get( $path, array( 'type' ) ) as $domain ) {
140
			$this->getSubManager( $domain )->cleanup( $siteids );
141
		}
142
143
		$this->cleanupBase( $siteids, 'mshop/customer/manager/lists/ezpublish/delete' );
144
	}
145
146
147
	/**
148
	 * Returns the list attributes that can be used for searching.
149
	 *
150
	 * @param boolean $withsub Return also attributes of sub-managers if true
151
	 * @return array List of attribute items implementing \Aimeos\MW\Criteria\Attribute\Iface
152
	 */
153
	public function getSearchAttributes( $withsub = true )
154
	{
155
		$path = 'mshop/customer/manager/lists/submanagers';
156
157
		return $this->getSearchAttributesBase( $this->searchConfig, $path, array( 'type' ), $withsub );
158
	}
159
160
161
	/**
162
	 * Returns a new manager for customer extensions
163
	 *
164
	 * @param string $manager Name of the sub manager type in lower case
165
	 * @param string|null $name Name of the implementation, will be from configuration (or Default) if null
166
	 * @return mixed Manager for different extensions, e.g stock, tags, locations, etc.
167
	 */
168
	public function getSubManager( $manager, $name = null )
169
	{
170
		return $this->getSubManagerBase( 'customer', 'lists/' . $manager, ( $name === null ? 'Ezpublish' : $name ) );
171
	}
172
173
174
	/**
175
	 * Returns the config path for retrieving the configuration values.
176
	 *
177
	 * @return string Configuration path (mshop/customer/manager/lists/ezpublish/)
178
	 */
179
	protected function getConfigPath()
180
	{
181
		return 'mshop/customer/manager/lists/ezpublish/';
182
	}
183
184
185
	/**
186
	 * Returns the search configuration for searching items.
187
	 *
188
	 * @return array Associative list of search keys and search definitions
189
	 */
190
	protected function getSearchConfig()
191
	{
192
		return $this->searchConfig;
193
	}
194
}
195