| Conditions | 11 |
| Paths | 513 |
| Total Lines | 34 |
| Code Lines | 22 |
| 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 |
||
| 25 | public function denormalize($data, $class, $format = null, array $context = array()) |
||
| 26 | { |
||
| 27 | if (!is_object($data)) { |
||
| 28 | throw new InvalidArgumentException(); |
||
| 29 | } |
||
| 30 | $object = new \Starweb\Api\Generated\Model\MediaFileModel(); |
||
| 31 | if (property_exists($data, 'mediaFileId')) { |
||
| 32 | $object->setMediaFileId($data->{'mediaFileId'}); |
||
| 33 | } |
||
| 34 | if (property_exists($data, 'name')) { |
||
| 35 | $object->setName($data->{'name'}); |
||
| 36 | } |
||
| 37 | if (property_exists($data, 'createdAt')) { |
||
| 38 | $object->setCreatedAt($data->{'createdAt'}); |
||
| 39 | } |
||
| 40 | if (property_exists($data, 'modifiedAt')) { |
||
| 41 | $object->setModifiedAt($data->{'modifiedAt'}); |
||
| 42 | } |
||
| 43 | if (property_exists($data, 'size')) { |
||
| 44 | $object->setSize($data->{'size'}); |
||
| 45 | } |
||
| 46 | if (property_exists($data, 'mime')) { |
||
| 47 | $object->setMime($data->{'mime'}); |
||
| 48 | } |
||
| 49 | if (property_exists($data, 'height')) { |
||
| 50 | $object->setHeight($data->{'height'}); |
||
| 51 | } |
||
| 52 | if (property_exists($data, 'width')) { |
||
| 53 | $object->setWidth($data->{'width'}); |
||
| 54 | } |
||
| 55 | if (property_exists($data, 'url')) { |
||
| 56 | $object->setUrl($data->{'url'}); |
||
| 57 | } |
||
| 58 | return $object; |
||
| 59 | } |
||
| 92 | } |