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 |
||
9 | class Acl implements \Serializable |
||
10 | { |
||
11 | /** |
||
12 | * @var string |
||
13 | */ |
||
14 | private $id; |
||
15 | |||
16 | /** |
||
17 | * @var bool |
||
18 | */ |
||
19 | private $ignoreClassAcl; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $type; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | private $class; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private $permission; |
||
35 | |||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | private $group; |
||
40 | |||
41 | /** |
||
42 | * @var string |
||
43 | */ |
||
44 | private $label; |
||
45 | |||
46 | /** |
||
47 | * @var string |
||
48 | */ |
||
49 | private $description; |
||
50 | |||
51 | /** |
||
52 | * Constructor |
||
53 | * |
||
54 | * @param array $data |
||
55 | * @throws \InvalidArgumentException |
||
56 | * |
||
57 | * @SuppressWarnings(PHPMD.NPathComplexity) |
||
58 | */ |
||
59 | public function __construct(array $data = null) |
||
82 | |||
83 | /** |
||
84 | * Gets id of this ACL annotation |
||
85 | * |
||
86 | * @return string |
||
87 | */ |
||
88 | public function getId() |
||
92 | |||
93 | /** |
||
94 | * Indicates whether a class level ACL annotation should be ignored or not. |
||
95 | * |
||
96 | * This attribute can be used in ACL annotations declared on method level only. |
||
97 | * A default value for this attribute is false. It means that both method and |
||
98 | * class level ACLs is checked to decide whether an access is granted or not. |
||
99 | * |
||
100 | * @return bool |
||
101 | */ |
||
102 | public function getIgnoreClassAcl() |
||
106 | |||
107 | /** |
||
108 | * Gets ACL extension key |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | public function getType() |
||
116 | |||
117 | /** |
||
118 | * Gets ACL class name |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | public function getClass() |
||
126 | |||
127 | /** |
||
128 | * @param string $class |
||
129 | */ |
||
130 | public function setClass($class) |
||
134 | |||
135 | /** |
||
136 | * Gets ACL permission name |
||
137 | * |
||
138 | * @return string |
||
139 | */ |
||
140 | public function getPermission() |
||
144 | |||
145 | /** |
||
146 | * Sets ACL permission name |
||
147 | * |
||
148 | * @param string $permission |
||
149 | */ |
||
150 | public function setPermission($permission) |
||
154 | |||
155 | /** |
||
156 | * Gets ACL group name |
||
157 | * |
||
158 | * @return string |
||
159 | */ |
||
160 | public function getGroup() |
||
164 | |||
165 | /** |
||
166 | * Gets ACL label name |
||
167 | * |
||
168 | * @return string |
||
169 | */ |
||
170 | public function getLabel() |
||
174 | |||
175 | /** |
||
176 | * Gets ACL description |
||
177 | * |
||
178 | * @return string |
||
179 | */ |
||
180 | public function getDescription() |
||
184 | |||
185 | /** |
||
186 | * {@inheritdoc} |
||
187 | */ |
||
188 | public function serialize() |
||
203 | |||
204 | /** |
||
205 | * {@inheritdoc} |
||
206 | */ |
||
207 | public function unserialize($serialized) |
||
220 | |||
221 | /** |
||
222 | * The __set_state handler |
||
223 | * |
||
224 | * @param array $data Initialization array |
||
225 | * @return Acl A new instance of a Acl object |
||
226 | */ |
||
227 | // @codingStandardsIgnoreStart |
||
228 | public static function __set_state($data) |
||
242 | // @codingStandardsIgnoreEnd |
||
243 | } |
||
244 |