Conditions | 11 |
Paths | 512 |
Total Lines | 36 |
Code Lines | 23 |
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 |
||
77 | public function normalize($object, $format = null, array $context = []) |
||
78 | { |
||
79 | $data = new \stdClass(); |
||
80 | if (null !== $object->getId()) { |
||
81 | $data->{'Id'} = $object->getId(); |
||
82 | } |
||
83 | if (null !== $object->getCreatedAt()) { |
||
84 | $data->{'CreatedAt'} = $object->getCreatedAt()->format("Y-m-d\TH:i:sP"); |
||
85 | } |
||
86 | if (null !== $object->getUpdatedAt()) { |
||
87 | $data->{'UpdatedAt'} = $object->getUpdatedAt()->format("Y-m-d\TH:i:sP"); |
||
88 | } |
||
89 | if (null !== $object->getRootUrl()) { |
||
90 | $data->{'RootUrl'} = $object->getRootUrl(); |
||
91 | } |
||
92 | if (null !== $object->getName()) { |
||
93 | $data->{'Name'} = $object->getName(); |
||
94 | } |
||
95 | if (null !== $object->getGroups()) { |
||
96 | $values = []; |
||
97 | foreach ($object->getGroups() as $value) { |
||
98 | $values[] = $this->normalizer->normalize($value, 'json', $context); |
||
99 | } |
||
100 | $data->{'Groups'} = $values; |
||
101 | } |
||
102 | if (null !== $object->getIsVerified()) { |
||
103 | $data->{'IsVerified'} = $object->getIsVerified(); |
||
104 | } |
||
105 | if (null !== $object->getLicenseType()) { |
||
106 | $data->{'LicenseType'} = $object->getLicenseType(); |
||
107 | } |
||
108 | if (null !== $object->getAgentMode()) { |
||
109 | $data->{'AgentMode'} = $object->getAgentMode(); |
||
110 | } |
||
111 | |||
112 | return $data; |
||
113 | } |
||
115 |