| Conditions | 20 |
| Paths | 16385 |
| Total Lines | 65 |
| Code Lines | 44 |
| 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\ProductVariantModel(); |
||
| 31 | if (property_exists($data, 'sku')) { |
||
| 32 | $object->setSku($data->{'sku'}); |
||
| 33 | } |
||
| 34 | if (property_exists($data, 'isActive')) { |
||
| 35 | $object->setIsActive($data->{'isActive'}); |
||
| 36 | } |
||
| 37 | if (property_exists($data, 'sortIndex')) { |
||
| 38 | $object->setSortIndex($data->{'sortIndex'}); |
||
| 39 | } |
||
| 40 | if (property_exists($data, 'stockStatusId')) { |
||
| 41 | $object->setStockStatusId($data->{'stockStatusId'}); |
||
| 42 | } |
||
| 43 | if (property_exists($data, 'stockQuantity')) { |
||
| 44 | $object->setStockQuantity($data->{'stockQuantity'}); |
||
| 45 | } |
||
| 46 | if (property_exists($data, 'weightInKg')) { |
||
| 47 | $object->setWeightInKg($data->{'weightInKg'}); |
||
| 48 | } |
||
| 49 | if (property_exists($data, 'costPrice')) { |
||
| 50 | $object->setCostPrice($data->{'costPrice'}); |
||
| 51 | } |
||
| 52 | if (property_exists($data, 'ean')) { |
||
| 53 | $object->setEan($data->{'ean'}); |
||
| 54 | } |
||
| 55 | if (property_exists($data, 'mpn')) { |
||
| 56 | $object->setMpn($data->{'mpn'}); |
||
| 57 | } |
||
| 58 | if (property_exists($data, 'imageFileId')) { |
||
| 59 | $object->setImageFileId($data->{'imageFileId'}); |
||
| 60 | } |
||
| 61 | if (property_exists($data, 'attributeValueLinks')) { |
||
| 62 | $values = array(); |
||
| 63 | foreach ($data->{'attributeValueLinks'} as $value) { |
||
| 64 | $values[] = $value; |
||
| 65 | } |
||
| 66 | $object->setAttributeValueLinks($values); |
||
| 67 | } |
||
| 68 | if (property_exists($data, 'volumePricingInheritancePricelistIds')) { |
||
| 69 | $values_1 = array(); |
||
| 70 | foreach ($data->{'volumePricingInheritancePricelistIds'} as $value_1) { |
||
| 71 | $values_1[] = $value_1; |
||
| 72 | } |
||
| 73 | $object->setVolumePricingInheritancePricelistIds($values_1); |
||
| 74 | } |
||
| 75 | if (property_exists($data, 'prices')) { |
||
| 76 | $values_2 = array(); |
||
| 77 | foreach ($data->{'prices'} as $value_2) { |
||
| 78 | $values_2[] = $this->denormalizer->denormalize($value_2, 'Starweb\\Api\\Generated\\Model\\ProductVariantPriceModel', 'json', $context); |
||
| 79 | } |
||
| 80 | $object->setPrices($values_2); |
||
| 81 | } |
||
| 82 | if (property_exists($data, 'attributeValues')) { |
||
| 83 | $values_3 = array(); |
||
| 84 | foreach ($data->{'attributeValues'} as $value_3) { |
||
| 85 | $values_3[] = $this->denormalizer->denormalize($value_3, 'Starweb\\Api\\Generated\\Model\\ProductVariantAttributeValueModel', 'json', $context); |
||
| 86 | } |
||
| 87 | $object->setAttributeValues($values_3); |
||
| 88 | } |
||
| 89 | return $object; |
||
| 90 | } |
||
| 144 | } |