Conditions | 10 |
Paths | 512 |
Total Lines | 32 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
73 | public function normalize($object, $format = null, array $context = []) |
||
74 | { |
||
75 | $data = new \stdClass(); |
||
76 | if (null !== $object->getDisabled()) { |
||
77 | $data->{'Disabled'} = $object->getDisabled(); |
||
78 | } |
||
79 | if (null !== $object->getId()) { |
||
80 | $data->{'Id'} = $object->getId(); |
||
81 | } |
||
82 | if (null !== $object->getIsMaxScanDurationEnabled()) { |
||
83 | $data->{'IsMaxScanDurationEnabled'} = $object->getIsMaxScanDurationEnabled(); |
||
84 | } |
||
85 | if (null !== $object->getMaxScanDuration()) { |
||
86 | $data->{'MaxScanDuration'} = $object->getMaxScanDuration(); |
||
87 | } |
||
88 | if (null !== $object->getName()) { |
||
89 | $data->{'Name'} = $object->getName(); |
||
90 | } |
||
91 | if (null !== $object->getNextExecutionTime()) { |
||
92 | $data->{'NextExecutionTime'} = $object->getNextExecutionTime(); |
||
93 | } |
||
94 | if (null !== $object->getScheduleRunType()) { |
||
95 | $data->{'ScheduleRunType'} = $object->getScheduleRunType(); |
||
96 | } |
||
97 | if (null !== $object->getAgentName()) { |
||
98 | $data->{'AgentName'} = $object->getAgentName(); |
||
99 | } |
||
100 | if (null !== $object->getBaseScanId()) { |
||
101 | $data->{'BaseScanId'} = $object->getBaseScanId(); |
||
102 | } |
||
103 | |||
104 | return $data; |
||
105 | } |
||
107 |