Complex classes like Rule often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Rule, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
8 | class Rule extends Entity |
||
9 | { |
||
10 | /** |
||
11 | * @param array $array |
||
12 | */ |
||
13 | 84 | public function __construct(array $array = []) |
|
17 | |||
18 | /** |
||
19 | * Sets the 'id' parameter. |
||
20 | * |
||
21 | * @param string $id |
||
22 | * |
||
23 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
24 | * |
||
25 | * @return \Acquia\LiftClient\Entity\Rule |
||
26 | */ |
||
27 | 33 | public function setId($id) |
|
36 | |||
37 | /** |
||
38 | * Gets the 'id' parameter. |
||
39 | * |
||
40 | * @return string The Identifier of the Rule |
||
41 | */ |
||
42 | 12 | public function getId() |
|
46 | |||
47 | /** |
||
48 | * Sets the 'label' parameter. |
||
49 | * |
||
50 | * @param string $label |
||
51 | * |
||
52 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
53 | * |
||
54 | * @return \Acquia\LiftClient\Entity\Rule |
||
55 | */ |
||
56 | 33 | public function setLabel($label) |
|
65 | |||
66 | /** |
||
67 | * Gets the 'label' parameter. |
||
68 | * |
||
69 | * @return string |
||
70 | */ |
||
71 | 12 | public function getLabel() |
|
75 | |||
76 | /** |
||
77 | * Sets the 'description' parameter. |
||
78 | * |
||
79 | * @param string $description |
||
80 | * |
||
81 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
82 | * |
||
83 | * @return \Acquia\LiftClient\Entity\Rule |
||
84 | */ |
||
85 | 33 | public function setDescription($description) |
|
94 | |||
95 | /** |
||
96 | * Gets the 'description' parameter. |
||
97 | * |
||
98 | * @return string The Description of the Rule |
||
99 | */ |
||
100 | 12 | public function getDescription() |
|
104 | |||
105 | /** |
||
106 | * Sets the 'slot_id' parameter. |
||
107 | * |
||
108 | * @param string $slotId |
||
109 | * |
||
110 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
111 | * |
||
112 | * @return \Acquia\LiftClient\Entity\Rule |
||
113 | */ |
||
114 | 33 | public function setSlotId($slotId) |
|
123 | |||
124 | /** |
||
125 | * Gets the 'slot_id' parameter. |
||
126 | * |
||
127 | * @return string The Description of the Rule |
||
128 | */ |
||
129 | 12 | public function getSlotId() |
|
133 | |||
134 | /** |
||
135 | * Sets the 'priority' parameter. |
||
136 | * |
||
137 | * Higher number means the rule display / apply first. |
||
138 | * |
||
139 | * @param int $priority |
||
140 | * |
||
141 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
142 | * |
||
143 | * @return \Acquia\LiftClient\Entity\Rule |
||
144 | */ |
||
145 | 33 | public function setPriority($priority) |
|
154 | |||
155 | /** |
||
156 | * Gets the 'priority' parameter. |
||
157 | * |
||
158 | * @return int The priority of the Rule |
||
159 | */ |
||
160 | 12 | public function getPriority() |
|
164 | |||
165 | /** |
||
166 | * Sets the 'weight' parameter. |
||
167 | * |
||
168 | * @deprecated use the priority parameter instead. |
||
169 | * @param int $weight |
||
170 | * |
||
171 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
172 | * |
||
173 | * @return \Acquia\LiftClient\Entity\Rule |
||
174 | */ |
||
175 | public function setWeight($weight) |
||
179 | |||
180 | /** |
||
181 | * Gets the 'weight' parameter. |
||
182 | * |
||
183 | * @deprecated use the priority parameter instead. |
||
184 | * @return int The weight of the Rule |
||
185 | */ |
||
186 | public function getWeight() |
||
190 | |||
191 | /** |
||
192 | * Sets the 'content' parameter. |
||
193 | * |
||
194 | * @param Content[] $contentList |
||
195 | * |
||
196 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
197 | * |
||
198 | * @return \Acquia\LiftClient\Entity\Rule |
||
199 | */ |
||
200 | 30 | public function setContentList(array $contentList) |
|
210 | |||
211 | /** |
||
212 | * Gets the 'content' parameter. |
||
213 | * |
||
214 | * @return Content[] The list of content this rule applies to |
||
215 | */ |
||
216 | 12 | public function getContentList() |
|
226 | |||
227 | /** |
||
228 | * Sets the 'segment' parameter. |
||
229 | * |
||
230 | * @param string $segment |
||
231 | * |
||
232 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
233 | * |
||
234 | * @return \Acquia\LiftClient\Entity\Rule |
||
235 | */ |
||
236 | 33 | public function setSegmentId($segment) |
|
245 | |||
246 | /** |
||
247 | * Gets the 'segment' parameter. |
||
248 | * |
||
249 | * @return string |
||
250 | */ |
||
251 | 12 | public function getSegmentId() |
|
255 | |||
256 | /** |
||
257 | * Sets the 'status' parameter. |
||
258 | * |
||
259 | * @param string $status |
||
260 | * |
||
261 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
262 | * |
||
263 | * @return \Acquia\LiftClient\Entity\Rule |
||
264 | */ |
||
265 | 36 | public function setStatus($status) |
|
277 | |||
278 | /** |
||
279 | * Gets the 'status' parameter. |
||
280 | * |
||
281 | * @return string |
||
282 | */ |
||
283 | 12 | public function getStatus() |
|
287 | |||
288 | /** |
||
289 | * Gets the 'created' parameter. |
||
290 | * |
||
291 | * @return DateTime|false |
||
292 | */ |
||
293 | 12 | public function getCreated() |
|
303 | |||
304 | /** |
||
305 | * Gets the 'updated' parameter. |
||
306 | * |
||
307 | * @return DateTime|false |
||
308 | */ |
||
309 | 12 | public function getUpdated() |
|
319 | |||
320 | /** |
||
321 | * Sets the Rule test_config property. |
||
322 | * |
||
323 | * @param \Acquia\LiftClient\Entity\TestConfigInterface $testConfig |
||
324 | * |
||
325 | * @return \Acquia\LiftClient\Entity\Rule |
||
326 | */ |
||
327 | 30 | public function setTestConfig(TestConfigInterface $testConfig) |
|
353 | |||
354 | /** |
||
355 | * Gets the 'test_config' parameter. |
||
356 | * |
||
357 | * @return \Acquia\LiftClient\Entity\TestConfigInterface|null $testConfig |
||
358 | */ |
||
359 | 12 | public function getTestConfig() |
|
379 | } |
||
380 |