Conditions | 11 |
Paths | 1024 |
Total Lines | 35 |
Code Lines | 22 |
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 |
||
76 | public function normalize($object, $format = null, array $context = []) |
||
77 | { |
||
78 | $data = new \stdClass(); |
||
79 | if (null !== $object->getId()) { |
||
80 | $data->{'Id'} = $object->getId(); |
||
81 | } |
||
82 | if (null !== $object->getPriority()) { |
||
83 | $data->{'Priority'} = $object->getPriority(); |
||
84 | } |
||
85 | if (null !== $object->getRecipients()) { |
||
86 | $data->{'Recipients'} = $this->normalizer->normalize($object->getRecipients(), 'json', $context); |
||
87 | } |
||
88 | if (null !== $object->getWebsiteGroupName()) { |
||
89 | $data->{'WebsiteGroupName'} = $object->getWebsiteGroupName(); |
||
90 | } |
||
91 | if (null !== $object->getWebsiteRootUrl()) { |
||
92 | $data->{'WebsiteRootUrl'} = $object->getWebsiteRootUrl(); |
||
93 | } |
||
94 | if (null !== $object->getDisabled()) { |
||
95 | $data->{'Disabled'} = $object->getDisabled(); |
||
96 | } |
||
97 | if (null !== $object->getEvent()) { |
||
98 | $data->{'Event'} = $object->getEvent(); |
||
99 | } |
||
100 | if (null !== $object->getLowestSeverity()) { |
||
101 | $data->{'LowestSeverity'} = $object->getLowestSeverity(); |
||
102 | } |
||
103 | if (null !== $object->getName()) { |
||
104 | $data->{'Name'} = $object->getName(); |
||
105 | } |
||
106 | if (null !== $object->getScope()) { |
||
107 | $data->{'Scope'} = $object->getScope(); |
||
108 | } |
||
109 | |||
110 | return $data; |
||
111 | } |
||
113 |