| Conditions | 17 |
| Paths | 16385 |
| Total Lines | 53 |
| Code Lines | 35 |
| 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\PaymentMethodModel(); |
||
| 31 | if (property_exists($data, 'paymentMethodId')) { |
||
| 32 | $object->setPaymentMethodId($data->{'paymentMethodId'}); |
||
| 33 | } |
||
| 34 | if (property_exists($data, 'idCode')) { |
||
| 35 | $object->setIdCode($data->{'idCode'}); |
||
| 36 | } |
||
| 37 | if (property_exists($data, 'active')) { |
||
| 38 | $object->setActive($data->{'active'}); |
||
| 39 | } |
||
| 40 | if (property_exists($data, 'fee')) { |
||
| 41 | $object->setFee($data->{'fee'}); |
||
| 42 | } |
||
| 43 | if (property_exists($data, 'validForCountries')) { |
||
| 44 | $object->setValidForCountries($data->{'validForCountries'}); |
||
| 45 | } |
||
| 46 | if (property_exists($data, 'validCountriesSelected')) { |
||
| 47 | $values = array(); |
||
| 48 | foreach ($data->{'validCountriesSelected'} as $value) { |
||
| 49 | $values[] = $value; |
||
| 50 | } |
||
| 51 | $object->setValidCountriesSelected($values); |
||
| 52 | } |
||
| 53 | if (property_exists($data, 'validForMinItemsSubtotal')) { |
||
| 54 | $object->setValidForMinItemsSubtotal($data->{'validForMinItemsSubtotal'}); |
||
| 55 | } |
||
| 56 | if (property_exists($data, 'validForMaxItemsSubtotal')) { |
||
| 57 | $object->setValidForMaxItemsSubtotal($data->{'validForMaxItemsSubtotal'}); |
||
| 58 | } |
||
| 59 | if (property_exists($data, 'validForMinWeight')) { |
||
| 60 | $object->setValidForMinWeight($data->{'validForMinWeight'}); |
||
| 61 | } |
||
| 62 | if (property_exists($data, 'validForMaxWeight')) { |
||
| 63 | $object->setValidForMaxWeight($data->{'validForMaxWeight'}); |
||
| 64 | } |
||
| 65 | if (property_exists($data, 'validForShippingMethods')) { |
||
| 66 | $object->setValidForShippingMethods($data->{'validForShippingMethods'}); |
||
| 67 | } |
||
| 68 | if (property_exists($data, 'validForCustomerType')) { |
||
| 69 | $object->setValidForCustomerType($data->{'validForCustomerType'}); |
||
| 70 | } |
||
| 71 | if (property_exists($data, 'isClickAndCollect')) { |
||
| 72 | $object->setIsClickAndCollect($data->{'isClickAndCollect'}); |
||
| 73 | } |
||
| 74 | if (property_exists($data, 'languages')) { |
||
| 75 | $object->setLanguages($this->denormalizer->denormalize($data->{'languages'}, 'Starweb\\Api\\Generated\\Model\\PaymentMethodLanguageModelCollection', 'json', $context)); |
||
|
|
|||
| 76 | } |
||
| 77 | return $object; |
||
| 78 | } |
||
| 120 | } |