Complex classes like GExpressionTrait 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 GExpressionTrait, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
20 | trait GExpressionTrait |
||
21 | { |
||
22 | use XSDTopLevelTrait, IsOKToolboxTrait; |
||
23 | |||
24 | private $gExpressionMinimum = -1; |
||
25 | private $gExpressionMaximum = -1; |
||
26 | |||
27 | private $gExpressionSimpleFieldNames = ['string', 'binary', 'int', 'float', 'guid', 'decimal', 'bool', 'dateTime', |
||
28 | 'dateTimeOffset', 'enum', 'path']; |
||
29 | private $gExpressionObjectFieldTypes = [ |
||
30 | 'if' => '\AlgoWeb\ODataMetadata\MetadataV3\edm\TIfExpressionType', |
||
31 | 'record' => '\AlgoWeb\ODataMetadata\MetadataV3\edm\TRecordExpressionType', |
||
32 | 'collection' => '\AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionExpressionType', |
||
33 | 'typeAssert' => '\AlgoWeb\ODataMetadata\MetadataV3\edm\TTypeAssertExpressionType', |
||
34 | 'typeTest' => '\AlgoWeb\ODataMetadata\MetadataV3\edm\TTypeTestExpressionType', |
||
35 | 'functionReference' => '\AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReferenceExpressionType', |
||
36 | 'entitySetReference' => '\AlgoWeb\ODataMetadata\MetadataV3\edm\TEntitySetReferenceExpressionType', |
||
37 | 'anonymousFunction' => '\AlgoWeb\ODataMetadata\MetadataV3\edm\TAnonymousFunctionExpressionType', |
||
38 | 'parameterReference' => '\AlgoWeb\ODataMetadata\MetadataV3\edm\TParameterReferenceExpressionType', |
||
39 | 'apply' => '\AlgoWeb\ODataMetadata\MetadataV3\edm\TApplyExpressionType', |
||
40 | 'propertyReference' => '\AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyReferenceExpressionType', |
||
41 | 'valueTermReference' => '\AlgoWeb\ODataMetadata\MetadataV3\edm\TValueTermReferenceExpressionType' |
||
42 | ]; |
||
43 | |||
44 | /** |
||
45 | * @property string $string |
||
46 | */ |
||
47 | private $string = null; |
||
48 | |||
49 | /** |
||
50 | * @property mixed $binary |
||
51 | */ |
||
52 | private $binary = null; |
||
53 | |||
54 | /** |
||
55 | * @property integer $int |
||
56 | */ |
||
57 | private $int = null; |
||
58 | |||
59 | /** |
||
60 | * @property float $float |
||
61 | */ |
||
62 | private $float = null; |
||
63 | |||
64 | /** |
||
65 | * @property string $guid |
||
66 | */ |
||
67 | private $guid = null; |
||
68 | |||
69 | /** |
||
70 | * @property float $decimal |
||
71 | */ |
||
72 | private $decimal = null; |
||
73 | |||
74 | /** |
||
75 | * @property boolean $bool |
||
76 | */ |
||
77 | private $bool = null; |
||
78 | |||
79 | /** |
||
80 | * @property \DateTime $dateTime |
||
81 | */ |
||
82 | private $dateTime = null; |
||
83 | |||
84 | /** |
||
85 | * @property \DateTime $dateTimeOffset |
||
86 | */ |
||
87 | private $dateTimeOffset = null; |
||
88 | |||
89 | /** |
||
90 | * @property string $enum |
||
91 | */ |
||
92 | private $enum = null; |
||
93 | |||
94 | /** |
||
95 | * @property string $path |
||
96 | */ |
||
97 | private $path = null; |
||
98 | |||
99 | /** |
||
100 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TIfExpressionType $if |
||
101 | */ |
||
102 | private $if = null; |
||
103 | |||
104 | /** |
||
105 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TRecordExpressionType $record |
||
106 | */ |
||
107 | private $record = null; |
||
108 | |||
109 | /** |
||
110 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionExpressionType $collection |
||
111 | */ |
||
112 | private $collection = null; |
||
113 | |||
114 | /** |
||
115 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TTypeAssertExpressionType $typeAssert |
||
116 | */ |
||
117 | private $typeAssert = null; |
||
118 | |||
119 | /** |
||
120 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TTypeTestExpressionType $typeTest |
||
121 | */ |
||
122 | private $typeTest = null; |
||
123 | |||
124 | /** |
||
125 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReferenceExpressionType $functionReference |
||
126 | */ |
||
127 | private $functionReference = null; |
||
128 | |||
129 | /** |
||
130 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TEntitySetReferenceExpressionType $entitySetReference |
||
131 | */ |
||
132 | private $entitySetReference = null; |
||
133 | |||
134 | /** |
||
135 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TAnonymousFunctionExpressionType $anonymousFunction |
||
136 | */ |
||
137 | private $anonymousFunction = null; |
||
138 | |||
139 | /** |
||
140 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TParameterReferenceExpressionType $parameterReference |
||
141 | */ |
||
142 | private $parameterReference = null; |
||
143 | |||
144 | /** |
||
145 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TApplyExpressionType $apply |
||
146 | */ |
||
147 | private $apply = null; |
||
148 | |||
149 | /** |
||
150 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyReferenceExpressionType $propertyReference |
||
151 | */ |
||
152 | private $propertyReference = null; |
||
153 | |||
154 | /** |
||
155 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TValueTermReferenceExpressionType $valueTermReference |
||
156 | */ |
||
157 | private $valueTermReference = null; |
||
158 | |||
159 | /** |
||
160 | * Gets as string |
||
161 | * |
||
162 | * @return string |
||
163 | */ |
||
164 | public function getString() |
||
168 | |||
169 | /** |
||
170 | * Sets a new string |
||
171 | * |
||
172 | * @param string $string |
||
173 | * @return self |
||
174 | */ |
||
175 | public function setString($string) |
||
180 | |||
181 | /** |
||
182 | * Gets as binary |
||
183 | * |
||
184 | * @return mixed |
||
185 | */ |
||
186 | public function getBinary() |
||
190 | |||
191 | /** |
||
192 | * Sets a new binary |
||
193 | * |
||
194 | * @param mixed $binary |
||
195 | * @return self |
||
196 | */ |
||
197 | public function setBinary($binary) |
||
202 | |||
203 | /** |
||
204 | * Gets as int |
||
205 | * |
||
206 | * @return integer |
||
207 | */ |
||
208 | public function getInt() |
||
212 | |||
213 | /** |
||
214 | * Sets a new int |
||
215 | * |
||
216 | * @param integer $int |
||
217 | * @return self |
||
218 | */ |
||
219 | public function setInt($int) |
||
224 | |||
225 | /** |
||
226 | * Gets as float |
||
227 | * |
||
228 | * @return float |
||
229 | */ |
||
230 | public function getFloat() |
||
234 | |||
235 | /** |
||
236 | * Sets a new float |
||
237 | * |
||
238 | * @param float $float |
||
239 | * @return self |
||
240 | */ |
||
241 | public function setFloat($float) |
||
246 | |||
247 | /** |
||
248 | * Gets as guid |
||
249 | * |
||
250 | * @return string |
||
251 | */ |
||
252 | public function getGuid() |
||
256 | |||
257 | /** |
||
258 | * Sets a new guid |
||
259 | * |
||
260 | * @param string $guid |
||
261 | * @return self |
||
262 | */ |
||
263 | public function setGuid($guid) |
||
268 | |||
269 | /** |
||
270 | * Gets as decimal |
||
271 | * |
||
272 | * @return float |
||
273 | */ |
||
274 | public function getDecimal() |
||
278 | |||
279 | /** |
||
280 | * Sets a new decimal |
||
281 | * |
||
282 | * @param float $decimal |
||
283 | * @return self |
||
284 | */ |
||
285 | public function setDecimal($decimal) |
||
290 | |||
291 | /** |
||
292 | * Gets as bool |
||
293 | * |
||
294 | * @return boolean |
||
295 | */ |
||
296 | public function getBool() |
||
300 | |||
301 | /** |
||
302 | * Sets a new bool |
||
303 | * |
||
304 | * @param boolean $bool |
||
305 | * @return self |
||
306 | */ |
||
307 | public function setBool($bool) |
||
312 | |||
313 | /** |
||
314 | * Gets as dateTime |
||
315 | * |
||
316 | * @return \DateTime |
||
317 | */ |
||
318 | public function getDateTime() |
||
322 | |||
323 | /** |
||
324 | * Sets a new dateTime |
||
325 | * |
||
326 | * @param \DateTime $dateTime |
||
327 | * @return self |
||
328 | */ |
||
329 | public function setDateTime(\DateTime $dateTime) |
||
334 | |||
335 | /** |
||
336 | * Gets as dateTimeOffset |
||
337 | * |
||
338 | * @return \DateTime |
||
339 | */ |
||
340 | public function getDateTimeOffset() |
||
344 | |||
345 | /** |
||
346 | * Sets a new dateTimeOffset |
||
347 | * |
||
348 | * @param \DateTime $dateTimeOffset |
||
349 | * @return self |
||
350 | */ |
||
351 | public function setDateTimeOffset(\DateTime $dateTimeOffset) |
||
356 | |||
357 | /** |
||
358 | * Gets as enum |
||
359 | * |
||
360 | * @return string |
||
361 | */ |
||
362 | public function getEnum() |
||
366 | |||
367 | /** |
||
368 | * Sets a new enum |
||
369 | * |
||
370 | * @param string $enum |
||
371 | * @return self |
||
372 | */ |
||
373 | public function setEnum($enum) |
||
378 | |||
379 | /** |
||
380 | * Gets as path |
||
381 | * |
||
382 | * @return string |
||
383 | */ |
||
384 | public function getPath() |
||
388 | |||
389 | /** |
||
390 | * Sets a new path |
||
391 | * |
||
392 | * @param string $path |
||
393 | * @return self |
||
394 | */ |
||
395 | public function setPath($path) |
||
400 | |||
401 | /** |
||
402 | * Gets as if |
||
403 | * |
||
404 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TIfExpressionType |
||
405 | */ |
||
406 | public function getIf() |
||
410 | |||
411 | /** |
||
412 | * Sets a new if |
||
413 | * |
||
414 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TIfExpressionType $if |
||
415 | * @return self |
||
416 | */ |
||
417 | public function setIf(TIfExpressionType $if) |
||
422 | |||
423 | /** |
||
424 | * Gets as record |
||
425 | * |
||
426 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TRecordExpressionType |
||
427 | */ |
||
428 | public function getRecord() |
||
432 | |||
433 | /** |
||
434 | * Sets a new record |
||
435 | * |
||
436 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TRecordExpressionType $record |
||
437 | * @return self |
||
438 | */ |
||
439 | public function setRecord(TRecordExpressionType $record) |
||
444 | |||
445 | /** |
||
446 | * Gets as collection |
||
447 | * |
||
448 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionExpressionType |
||
449 | */ |
||
450 | public function getCollection() |
||
454 | |||
455 | /** |
||
456 | * Sets a new collection |
||
457 | * |
||
458 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TCollectionExpressionType $collection |
||
459 | * @return self |
||
460 | */ |
||
461 | public function setCollection(TCollectionExpressionType $collection) |
||
466 | |||
467 | /** |
||
468 | * Gets as typeAssert |
||
469 | * |
||
470 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TTypeAssertExpressionType |
||
471 | */ |
||
472 | public function getTypeAssert() |
||
476 | |||
477 | /** |
||
478 | * Sets a new typeAssert |
||
479 | * |
||
480 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TTypeAssertExpressionType $typeAssert |
||
481 | * @return self |
||
482 | */ |
||
483 | public function setTypeAssert(TTypeAssertExpressionType $typeAssert) |
||
488 | |||
489 | /** |
||
490 | * Gets as typeTest |
||
491 | * |
||
492 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TTypeTestExpressionType |
||
493 | */ |
||
494 | public function getTypeTest() |
||
498 | |||
499 | /** |
||
500 | * Sets a new typeTest |
||
501 | * |
||
502 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TTypeTestExpressionType $typeTest |
||
503 | * @return self |
||
504 | */ |
||
505 | public function setTypeTest(TTypeTestExpressionType $typeTest) |
||
510 | |||
511 | /** |
||
512 | * Gets as functionReference |
||
513 | * |
||
514 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReferenceExpressionType |
||
515 | */ |
||
516 | public function getFunctionReference() |
||
520 | |||
521 | /** |
||
522 | * Sets a new functionReference |
||
523 | * |
||
524 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReferenceExpressionType $functionReference |
||
525 | * @return self |
||
526 | */ |
||
527 | public function setFunctionReference(TFunctionReferenceExpressionType $functionReference) |
||
532 | |||
533 | /** |
||
534 | * Gets as entitySetReference |
||
535 | * |
||
536 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TEntitySetReferenceExpressionType |
||
537 | */ |
||
538 | public function getEntitySetReference() |
||
542 | |||
543 | /** |
||
544 | * Sets a new entitySetReference |
||
545 | * |
||
546 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TEntitySetReferenceExpressionType $entitySetReference |
||
547 | * @return self |
||
548 | */ |
||
549 | public function setEntitySetReference(TEntitySetReferenceExpressionType $entitySetReference) |
||
554 | |||
555 | /** |
||
556 | * Gets as anonymousFunction |
||
557 | * |
||
558 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TAnonymousFunctionExpressionType |
||
559 | */ |
||
560 | public function getAnonymousFunction() |
||
564 | |||
565 | /** |
||
566 | * Sets a new anonymousFunction |
||
567 | * |
||
568 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TAnonymousFunctionExpressionType $anonymousFunction |
||
569 | * @return self |
||
570 | */ |
||
571 | public function setAnonymousFunction(TAnonymousFunctionExpressionType $anonymousFunction) |
||
576 | |||
577 | /** |
||
578 | * Gets as parameterReference |
||
579 | * |
||
580 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TParameterReferenceExpressionType |
||
581 | */ |
||
582 | public function getParameterReference() |
||
586 | |||
587 | /** |
||
588 | * Sets a new parameterReference |
||
589 | * |
||
590 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TParameterReferenceExpressionType $parameterReference |
||
591 | * @return self |
||
592 | */ |
||
593 | public function setParameterReference(TParameterReferenceExpressionType $parameterReference) |
||
598 | |||
599 | /** |
||
600 | * Gets as apply |
||
601 | * |
||
602 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TApplyExpressionType |
||
603 | */ |
||
604 | public function getApply() |
||
608 | |||
609 | /** |
||
610 | * Sets a new apply |
||
611 | * |
||
612 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TApplyExpressionType $apply |
||
613 | * @return self |
||
614 | */ |
||
615 | public function setApply(TApplyExpressionType $apply) |
||
620 | |||
621 | /** |
||
622 | * Gets as propertyReference |
||
623 | * |
||
624 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyReferenceExpressionType |
||
625 | */ |
||
626 | public function getPropertyReference() |
||
630 | |||
631 | /** |
||
632 | * Sets a new propertyReference |
||
633 | * |
||
634 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyReferenceExpressionType $propertyReference |
||
635 | * @return self |
||
636 | */ |
||
637 | public function setPropertyReference(TPropertyReferenceExpressionType $propertyReference) |
||
642 | |||
643 | /** |
||
644 | * Gets as valueTermReference |
||
645 | * |
||
646 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TValueTermReferenceExpressionType |
||
647 | */ |
||
648 | public function getValueTermReference() |
||
652 | |||
653 | /** |
||
654 | * Sets a new valueTermReference |
||
655 | * |
||
656 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TValueTermReferenceExpressionType $valueTermReference |
||
657 | * @return self |
||
658 | */ |
||
659 | public function setValueTermReference(TValueTermReferenceExpressionType $valueTermReference) |
||
664 | |||
665 | public function isGExpressionValid(&$msg = null) |
||
697 | } |
||
698 |