Conditions | 10 |
Paths | 512 |
Total Lines | 31 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
60 | public function normalize($object, $format = null, array $context = array()) |
||
61 | { |
||
62 | $data = new \stdClass(); |
||
63 | if (null !== $object->getMediaFileId()) { |
||
64 | $data->{'mediaFileId'} = $object->getMediaFileId(); |
||
65 | } |
||
66 | if (null !== $object->getName()) { |
||
67 | $data->{'name'} = $object->getName(); |
||
68 | } |
||
69 | if (null !== $object->getCreatedAt()) { |
||
70 | $data->{'createdAt'} = $object->getCreatedAt(); |
||
71 | } |
||
72 | if (null !== $object->getModifiedAt()) { |
||
73 | $data->{'modifiedAt'} = $object->getModifiedAt(); |
||
74 | } |
||
75 | if (null !== $object->getSize()) { |
||
76 | $data->{'size'} = $object->getSize(); |
||
77 | } |
||
78 | if (null !== $object->getMime()) { |
||
79 | $data->{'mime'} = $object->getMime(); |
||
80 | } |
||
81 | if (null !== $object->getHeight()) { |
||
82 | $data->{'height'} = $object->getHeight(); |
||
83 | } |
||
84 | if (null !== $object->getWidth()) { |
||
85 | $data->{'width'} = $object->getWidth(); |
||
86 | } |
||
87 | if (null !== $object->getUrl()) { |
||
88 | $data->{'url'} = $object->getUrl(); |
||
89 | } |
||
90 | return $data; |
||
91 | } |
||
92 | } |