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 | * @param int $priority |
||
138 | * |
||
139 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
140 | * |
||
141 | * @return \Acquia\LiftClient\Entity\Rule |
||
142 | */ |
||
143 | 33 | public function setPriority($priority) |
|
152 | |||
153 | /** |
||
154 | * Gets the 'priority' parameter. |
||
155 | * |
||
156 | * @return int The priority of the Rule |
||
157 | */ |
||
158 | 12 | public function getPriority() |
|
162 | |||
163 | /** |
||
164 | * Sets the 'weight' parameter. |
||
165 | * |
||
166 | * @deprecated use the priority parameter instead. |
||
167 | * @param int $weight |
||
168 | * |
||
169 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
170 | * |
||
171 | * @return \Acquia\LiftClient\Entity\Rule |
||
172 | 30 | */ |
|
173 | public function setWeight($weight) |
||
177 | 30 | ||
178 | 20 | /** |
|
179 | * Gets the 'weight' parameter. |
||
180 | 30 | * |
|
181 | * @deprecated use the priority parameter instead. |
||
182 | * @return int The weight of the Rule |
||
183 | */ |
||
184 | public function getWeight() |
||
188 | 12 | ||
189 | /** |
||
190 | 12 | * Sets the 'content' parameter. |
|
191 | 12 | * |
|
192 | 12 | * @param Content[] $contentList |
|
193 | 12 | * |
|
194 | 8 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
|
195 | * |
||
196 | 12 | * @return \Acquia\LiftClient\Entity\Rule |
|
197 | */ |
||
198 | public function setContentList(array $contentList) |
||
208 | 33 | ||
209 | /** |
||
210 | 33 | * Gets the 'content' parameter. |
|
211 | 3 | * |
|
212 | * @return Content[] The list of content this rule applies to |
||
213 | 30 | */ |
|
214 | public function getContentList() |
||
224 | |||
225 | 12 | /** |
|
226 | * Sets the 'segment' parameter. |
||
227 | * |
||
228 | * @param string $segment |
||
229 | * |
||
230 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
231 | * |
||
232 | * @return \Acquia\LiftClient\Entity\Rule |
||
233 | */ |
||
234 | public function setSegmentId($segment) |
||
243 | 3 | ||
244 | /** |
||
245 | 30 | * Gets the 'segment' parameter. |
|
246 | * |
||
247 | 30 | * @return string |
|
248 | */ |
||
249 | public function getSegmentId() |
||
253 | |||
254 | /** |
||
255 | 12 | * Sets the 'status' parameter. |
|
256 | * |
||
257 | 12 | * @param string $status |
|
258 | * |
||
259 | * @throws \Acquia\LiftClient\Exception\LiftSdkException |
||
260 | * |
||
261 | * @return \Acquia\LiftClient\Entity\Rule |
||
262 | */ |
||
263 | public function setStatus($status) |
||
275 | |||
276 | /** |
||
277 | * Gets the 'status' parameter. |
||
278 | * |
||
279 | * @return string |
||
280 | */ |
||
281 | 12 | public function getStatus() |
|
285 | |||
286 | /** |
||
287 | 12 | * Gets the 'created' parameter. |
|
288 | * |
||
289 | 12 | * @return DateTime|false |
|
290 | */ |
||
291 | public function getCreated() |
||
301 | |||
302 | /** |
||
303 | * Gets the 'updated' parameter. |
||
304 | * |
||
305 | * @return DateTime|false |
||
306 | */ |
||
307 | 30 | public function getUpdated() |
|
317 | 3 | ||
318 | 3 | /** |
|
319 | 3 | * Sets the Rule test_config property. |
|
320 | 3 | * |
|
321 | * @param \Acquia\LiftClient\Entity\TestConfigInterface $testConfig |
||
322 | * |
||
323 | 30 | * @return \Acquia\LiftClient\Entity\Rule |
|
324 | */ |
||
325 | public function setTestConfig(TestConfigInterface $testConfig) |
||
351 | |||
352 | /** |
||
353 | * Gets the 'test_config' parameter. |
||
354 | * |
||
355 | * @return \Acquia\LiftClient\Entity\TestConfigInterface|null $testConfig |
||
356 | */ |
||
357 | public function getTestConfig() |
||
377 | } |
||
378 |