Total Complexity | 61 |
Total Lines | 454 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like OperationStruct 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.
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 OperationStruct, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
12 | class OperationStruct extends AbstractStructBase |
||
13 | { |
||
14 | /** |
||
15 | * The id |
||
16 | * @var int |
||
17 | */ |
||
18 | public $id; |
||
19 | /** |
||
20 | * The domain |
||
21 | * @var string |
||
22 | */ |
||
23 | public $domain; |
||
24 | /** |
||
25 | * The function |
||
26 | * @var string |
||
27 | */ |
||
28 | public $function; |
||
29 | /** |
||
30 | * The status |
||
31 | * @var string |
||
32 | */ |
||
33 | public $status; |
||
34 | /** |
||
35 | * The internalStatus |
||
36 | * @var string |
||
37 | */ |
||
38 | public $internalStatus; |
||
39 | /** |
||
40 | * The comment |
||
41 | * @var string |
||
42 | */ |
||
43 | public $comment; |
||
44 | /** |
||
45 | * The users |
||
46 | * @var \Ovh\ArrayType\MyArrayOfStringType |
||
47 | */ |
||
48 | public $users; |
||
49 | /** |
||
50 | * The retry |
||
51 | * @var int |
||
52 | */ |
||
53 | public $retry; |
||
54 | /** |
||
55 | * The todoDate |
||
56 | * @var string |
||
57 | */ |
||
58 | public $todoDate; |
||
59 | /** |
||
60 | * The lastUpdate |
||
61 | * @var string |
||
62 | */ |
||
63 | public $lastUpdate; |
||
64 | /** |
||
65 | * The doneDate |
||
66 | * @var string |
||
67 | */ |
||
68 | public $doneDate; |
||
69 | /** |
||
70 | * The canCancel |
||
71 | * @var bool |
||
72 | */ |
||
73 | public $canCancel; |
||
74 | /** |
||
75 | * The canCorrect |
||
76 | * @var bool |
||
77 | */ |
||
78 | public $canCorrect; |
||
79 | /** |
||
80 | * The canRelaunch |
||
81 | * @var bool |
||
82 | */ |
||
83 | public $canRelaunch; |
||
84 | /** |
||
85 | * The restartStep |
||
86 | * @var string |
||
87 | */ |
||
88 | public $restartStep; |
||
89 | /** |
||
90 | * Constructor method for operationStruct |
||
91 | * @uses OperationStruct::setId() |
||
92 | * @uses OperationStruct::setDomain() |
||
93 | * @uses OperationStruct::setFunction() |
||
94 | * @uses OperationStruct::setStatus() |
||
95 | * @uses OperationStruct::setInternalStatus() |
||
96 | * @uses OperationStruct::setComment() |
||
97 | * @uses OperationStruct::setUsers() |
||
98 | * @uses OperationStruct::setRetry() |
||
99 | * @uses OperationStruct::setTodoDate() |
||
100 | * @uses OperationStruct::setLastUpdate() |
||
101 | * @uses OperationStruct::setDoneDate() |
||
102 | * @uses OperationStruct::setCanCancel() |
||
103 | * @uses OperationStruct::setCanCorrect() |
||
104 | * @uses OperationStruct::setCanRelaunch() |
||
105 | * @uses OperationStruct::setRestartStep() |
||
106 | * @param int $id |
||
107 | * @param string $domain |
||
108 | * @param string $function |
||
109 | * @param string $status |
||
110 | * @param string $internalStatus |
||
111 | * @param string $comment |
||
112 | * @param \Ovh\ArrayType\MyArrayOfStringType $users |
||
113 | * @param int $retry |
||
114 | * @param string $todoDate |
||
115 | * @param string $lastUpdate |
||
116 | * @param string $doneDate |
||
117 | * @param bool $canCancel |
||
118 | * @param bool $canCorrect |
||
119 | * @param bool $canRelaunch |
||
120 | * @param string $restartStep |
||
121 | */ |
||
122 | public function __construct($id = null, $domain = null, $function = null, $status = null, $internalStatus = null, $comment = null, \Ovh\ArrayType\MyArrayOfStringType $users = null, $retry = null, $todoDate = null, $lastUpdate = null, $doneDate = null, $canCancel = null, $canCorrect = null, $canRelaunch = null, $restartStep = null) |
||
123 | { |
||
124 | $this |
||
125 | ->setId($id) |
||
126 | ->setDomain($domain) |
||
127 | ->setFunction($function) |
||
128 | ->setStatus($status) |
||
129 | ->setInternalStatus($internalStatus) |
||
130 | ->setComment($comment) |
||
131 | ->setUsers($users) |
||
132 | ->setRetry($retry) |
||
133 | ->setTodoDate($todoDate) |
||
134 | ->setLastUpdate($lastUpdate) |
||
135 | ->setDoneDate($doneDate) |
||
136 | ->setCanCancel($canCancel) |
||
137 | ->setCanCorrect($canCorrect) |
||
138 | ->setCanRelaunch($canRelaunch) |
||
139 | ->setRestartStep($restartStep); |
||
140 | } |
||
141 | /** |
||
142 | * Get id value |
||
143 | * @return int|null |
||
144 | */ |
||
145 | public function getId() |
||
146 | { |
||
147 | return $this->id; |
||
148 | } |
||
149 | /** |
||
150 | * Set id value |
||
151 | * @param int $id |
||
152 | * @return \Ovh\StructType\OperationStruct |
||
153 | */ |
||
154 | public function setId($id = null) |
||
155 | { |
||
156 | // validation for constraint: int |
||
157 | if (!is_null($id) && !(is_int($id) || ctype_digit($id))) { |
||
|
|||
158 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide an integer value, %s given', var_export($id, true), gettype($id)), __LINE__); |
||
159 | } |
||
160 | $this->id = $id; |
||
161 | return $this; |
||
162 | } |
||
163 | /** |
||
164 | * Get domain value |
||
165 | * @return string|null |
||
166 | */ |
||
167 | public function getDomain() |
||
168 | { |
||
169 | return $this->domain; |
||
170 | } |
||
171 | /** |
||
172 | * Set domain value |
||
173 | * @param string $domain |
||
174 | * @return \Ovh\StructType\OperationStruct |
||
175 | */ |
||
176 | public function setDomain($domain = null) |
||
177 | { |
||
178 | // validation for constraint: string |
||
179 | if (!is_null($domain) && !is_string($domain)) { |
||
180 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($domain, true), gettype($domain)), __LINE__); |
||
181 | } |
||
182 | $this->domain = $domain; |
||
183 | return $this; |
||
184 | } |
||
185 | /** |
||
186 | * Get function value |
||
187 | * @return string|null |
||
188 | */ |
||
189 | public function getFunction() |
||
190 | { |
||
191 | return $this->function; |
||
192 | } |
||
193 | /** |
||
194 | * Set function value |
||
195 | * @param string $function |
||
196 | * @return \Ovh\StructType\OperationStruct |
||
197 | */ |
||
198 | public function setFunction($function = null) |
||
199 | { |
||
200 | // validation for constraint: string |
||
201 | if (!is_null($function) && !is_string($function)) { |
||
202 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($function, true), gettype($function)), __LINE__); |
||
203 | } |
||
204 | $this->function = $function; |
||
205 | return $this; |
||
206 | } |
||
207 | /** |
||
208 | * Get status value |
||
209 | * @return string|null |
||
210 | */ |
||
211 | public function getStatus() |
||
212 | { |
||
213 | return $this->status; |
||
214 | } |
||
215 | /** |
||
216 | * Set status value |
||
217 | * @param string $status |
||
218 | * @return \Ovh\StructType\OperationStruct |
||
219 | */ |
||
220 | public function setStatus($status = null) |
||
221 | { |
||
222 | // validation for constraint: string |
||
223 | if (!is_null($status) && !is_string($status)) { |
||
224 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($status, true), gettype($status)), __LINE__); |
||
225 | } |
||
226 | $this->status = $status; |
||
227 | return $this; |
||
228 | } |
||
229 | /** |
||
230 | * Get internalStatus value |
||
231 | * @return string|null |
||
232 | */ |
||
233 | public function getInternalStatus() |
||
234 | { |
||
235 | return $this->internalStatus; |
||
236 | } |
||
237 | /** |
||
238 | * Set internalStatus value |
||
239 | * @param string $internalStatus |
||
240 | * @return \Ovh\StructType\OperationStruct |
||
241 | */ |
||
242 | public function setInternalStatus($internalStatus = null) |
||
243 | { |
||
244 | // validation for constraint: string |
||
245 | if (!is_null($internalStatus) && !is_string($internalStatus)) { |
||
246 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($internalStatus, true), gettype($internalStatus)), __LINE__); |
||
247 | } |
||
248 | $this->internalStatus = $internalStatus; |
||
249 | return $this; |
||
250 | } |
||
251 | /** |
||
252 | * Get comment value |
||
253 | * @return string|null |
||
254 | */ |
||
255 | public function getComment() |
||
256 | { |
||
257 | return $this->comment; |
||
258 | } |
||
259 | /** |
||
260 | * Set comment value |
||
261 | * @param string $comment |
||
262 | * @return \Ovh\StructType\OperationStruct |
||
263 | */ |
||
264 | public function setComment($comment = null) |
||
265 | { |
||
266 | // validation for constraint: string |
||
267 | if (!is_null($comment) && !is_string($comment)) { |
||
268 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($comment, true), gettype($comment)), __LINE__); |
||
269 | } |
||
270 | $this->comment = $comment; |
||
271 | return $this; |
||
272 | } |
||
273 | /** |
||
274 | * Get users value |
||
275 | * @return \Ovh\ArrayType\MyArrayOfStringType|null |
||
276 | */ |
||
277 | public function getUsers() |
||
278 | { |
||
279 | return $this->users; |
||
280 | } |
||
281 | /** |
||
282 | * Set users value |
||
283 | * @param \Ovh\ArrayType\MyArrayOfStringType $users |
||
284 | * @return \Ovh\StructType\OperationStruct |
||
285 | */ |
||
286 | public function setUsers(\Ovh\ArrayType\MyArrayOfStringType $users = null) |
||
287 | { |
||
288 | $this->users = $users; |
||
289 | return $this; |
||
290 | } |
||
291 | /** |
||
292 | * Get retry value |
||
293 | * @return int|null |
||
294 | */ |
||
295 | public function getRetry() |
||
296 | { |
||
297 | return $this->retry; |
||
298 | } |
||
299 | /** |
||
300 | * Set retry value |
||
301 | * @param int $retry |
||
302 | * @return \Ovh\StructType\OperationStruct |
||
303 | */ |
||
304 | public function setRetry($retry = null) |
||
305 | { |
||
306 | // validation for constraint: int |
||
307 | if (!is_null($retry) && !(is_int($retry) || ctype_digit($retry))) { |
||
308 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide an integer value, %s given', var_export($retry, true), gettype($retry)), __LINE__); |
||
309 | } |
||
310 | $this->retry = $retry; |
||
311 | return $this; |
||
312 | } |
||
313 | /** |
||
314 | * Get todoDate value |
||
315 | * @return string|null |
||
316 | */ |
||
317 | public function getTodoDate() |
||
318 | { |
||
319 | return $this->todoDate; |
||
320 | } |
||
321 | /** |
||
322 | * Set todoDate value |
||
323 | * @param string $todoDate |
||
324 | * @return \Ovh\StructType\OperationStruct |
||
325 | */ |
||
326 | public function setTodoDate($todoDate = null) |
||
327 | { |
||
328 | // validation for constraint: string |
||
329 | if (!is_null($todoDate) && !is_string($todoDate)) { |
||
330 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($todoDate, true), gettype($todoDate)), __LINE__); |
||
331 | } |
||
332 | $this->todoDate = $todoDate; |
||
333 | return $this; |
||
334 | } |
||
335 | /** |
||
336 | * Get lastUpdate value |
||
337 | * @return string|null |
||
338 | */ |
||
339 | public function getLastUpdate() |
||
340 | { |
||
341 | return $this->lastUpdate; |
||
342 | } |
||
343 | /** |
||
344 | * Set lastUpdate value |
||
345 | * @param string $lastUpdate |
||
346 | * @return \Ovh\StructType\OperationStruct |
||
347 | */ |
||
348 | public function setLastUpdate($lastUpdate = null) |
||
349 | { |
||
350 | // validation for constraint: string |
||
351 | if (!is_null($lastUpdate) && !is_string($lastUpdate)) { |
||
352 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($lastUpdate, true), gettype($lastUpdate)), __LINE__); |
||
353 | } |
||
354 | $this->lastUpdate = $lastUpdate; |
||
355 | return $this; |
||
356 | } |
||
357 | /** |
||
358 | * Get doneDate value |
||
359 | * @return string|null |
||
360 | */ |
||
361 | public function getDoneDate() |
||
362 | { |
||
363 | return $this->doneDate; |
||
364 | } |
||
365 | /** |
||
366 | * Set doneDate value |
||
367 | * @param string $doneDate |
||
368 | * @return \Ovh\StructType\OperationStruct |
||
369 | */ |
||
370 | public function setDoneDate($doneDate = null) |
||
371 | { |
||
372 | // validation for constraint: string |
||
373 | if (!is_null($doneDate) && !is_string($doneDate)) { |
||
374 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($doneDate, true), gettype($doneDate)), __LINE__); |
||
375 | } |
||
376 | $this->doneDate = $doneDate; |
||
377 | return $this; |
||
378 | } |
||
379 | /** |
||
380 | * Get canCancel value |
||
381 | * @return bool|null |
||
382 | */ |
||
383 | public function getCanCancel() |
||
384 | { |
||
385 | return $this->canCancel; |
||
386 | } |
||
387 | /** |
||
388 | * Set canCancel value |
||
389 | * @param bool $canCancel |
||
390 | * @return \Ovh\StructType\OperationStruct |
||
391 | */ |
||
392 | public function setCanCancel($canCancel = null) |
||
393 | { |
||
394 | // validation for constraint: boolean |
||
395 | if (!is_null($canCancel) && !is_bool($canCancel)) { |
||
396 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a bool, %s given', var_export($canCancel, true), gettype($canCancel)), __LINE__); |
||
397 | } |
||
398 | $this->canCancel = $canCancel; |
||
399 | return $this; |
||
400 | } |
||
401 | /** |
||
402 | * Get canCorrect value |
||
403 | * @return bool|null |
||
404 | */ |
||
405 | public function getCanCorrect() |
||
406 | { |
||
407 | return $this->canCorrect; |
||
408 | } |
||
409 | /** |
||
410 | * Set canCorrect value |
||
411 | * @param bool $canCorrect |
||
412 | * @return \Ovh\StructType\OperationStruct |
||
413 | */ |
||
414 | public function setCanCorrect($canCorrect = null) |
||
415 | { |
||
416 | // validation for constraint: boolean |
||
417 | if (!is_null($canCorrect) && !is_bool($canCorrect)) { |
||
418 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a bool, %s given', var_export($canCorrect, true), gettype($canCorrect)), __LINE__); |
||
419 | } |
||
420 | $this->canCorrect = $canCorrect; |
||
421 | return $this; |
||
422 | } |
||
423 | /** |
||
424 | * Get canRelaunch value |
||
425 | * @return bool|null |
||
426 | */ |
||
427 | public function getCanRelaunch() |
||
428 | { |
||
429 | return $this->canRelaunch; |
||
430 | } |
||
431 | /** |
||
432 | * Set canRelaunch value |
||
433 | * @param bool $canRelaunch |
||
434 | * @return \Ovh\StructType\OperationStruct |
||
435 | */ |
||
436 | public function setCanRelaunch($canRelaunch = null) |
||
437 | { |
||
438 | // validation for constraint: boolean |
||
439 | if (!is_null($canRelaunch) && !is_bool($canRelaunch)) { |
||
440 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a bool, %s given', var_export($canRelaunch, true), gettype($canRelaunch)), __LINE__); |
||
441 | } |
||
442 | $this->canRelaunch = $canRelaunch; |
||
443 | return $this; |
||
444 | } |
||
445 | /** |
||
446 | * Get restartStep value |
||
447 | * @return string|null |
||
448 | */ |
||
449 | public function getRestartStep() |
||
452 | } |
||
453 | /** |
||
454 | * Set restartStep value |
||
455 | * @param string $restartStep |
||
456 | * @return \Ovh\StructType\OperationStruct |
||
457 | */ |
||
458 | public function setRestartStep($restartStep = null) |
||
459 | { |
||
460 | // validation for constraint: string |
||
461 | if (!is_null($restartStep) && !is_string($restartStep)) { |
||
462 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($restartStep, true), gettype($restartStep)), __LINE__); |
||
463 | } |
||
464 | $this->restartStep = $restartStep; |
||
465 | return $this; |
||
466 | } |
||
467 | } |
||
468 |