| Conditions | 12 |
| Paths | 1025 |
| Total Lines | 37 |
| Code Lines | 24 |
| 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\OrderItemModel(); |
||
| 31 | if (property_exists($data, 'itemId')) { |
||
| 32 | $object->setItemId($data->{'itemId'}); |
||
| 33 | } |
||
| 34 | if (property_exists($data, 'sku')) { |
||
| 35 | $object->setSku($data->{'sku'}); |
||
| 36 | } |
||
| 37 | if (property_exists($data, 'description')) { |
||
| 38 | $object->setDescription($data->{'description'}); |
||
| 39 | } |
||
| 40 | if (property_exists($data, 'quantity')) { |
||
| 41 | $object->setQuantity($data->{'quantity'}); |
||
| 42 | } |
||
| 43 | if (property_exists($data, 'unitSymbol')) { |
||
| 44 | $object->setUnitSymbol($data->{'unitSymbol'}); |
||
| 45 | } |
||
| 46 | if (property_exists($data, 'unitPrice')) { |
||
| 47 | $object->setUnitPrice($data->{'unitPrice'}); |
||
| 48 | } |
||
| 49 | if (property_exists($data, 'vatRate')) { |
||
| 50 | $object->setVatRate($data->{'vatRate'}); |
||
| 51 | } |
||
| 52 | if (property_exists($data, 'discount')) { |
||
| 53 | $object->setDiscount($data->{'discount'}); |
||
| 54 | } |
||
| 55 | if (property_exists($data, 'discountType')) { |
||
| 56 | $object->setDiscountType($data->{'discountType'}); |
||
| 57 | } |
||
| 58 | if (property_exists($data, 'sortIndex')) { |
||
| 59 | $object->setSortIndex($data->{'sortIndex'}); |
||
| 60 | } |
||
| 61 | return $object; |
||
| 62 | } |
||
| 98 | } |