| Conditions | 13 |
| Paths | 1025 |
| Total Lines | 41 |
| Code Lines | 27 |
| 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\PricelistModel(); |
||
| 31 | if (property_exists($data, 'pricelistId')) { |
||
| 32 | $object->setPricelistId($data->{'pricelistId'}); |
||
| 33 | } |
||
| 34 | if (property_exists($data, 'name')) { |
||
| 35 | $object->setName($data->{'name'}); |
||
| 36 | } |
||
| 37 | if (property_exists($data, 'isMaster')) { |
||
| 38 | $object->setIsMaster($data->{'isMaster'}); |
||
| 39 | } |
||
| 40 | if (property_exists($data, 'isActive')) { |
||
| 41 | $object->setIsActive($data->{'isActive'}); |
||
| 42 | } |
||
| 43 | if (property_exists($data, 'region')) { |
||
| 44 | $object->setRegion($data->{'region'}); |
||
| 45 | } |
||
| 46 | if (property_exists($data, 'countryCodes')) { |
||
| 47 | $values = array(); |
||
| 48 | foreach ($data->{'countryCodes'} as $value) { |
||
| 49 | $values[] = $value; |
||
| 50 | } |
||
| 51 | $object->setCountryCodes($values); |
||
| 52 | } |
||
| 53 | if (property_exists($data, 'currencyCode')) { |
||
| 54 | $object->setCurrencyCode($data->{'currencyCode'}); |
||
| 55 | } |
||
| 56 | if (property_exists($data, 'parentPricelistId')) { |
||
| 57 | $object->setParentPricelistId($data->{'parentPricelistId'}); |
||
| 58 | } |
||
| 59 | if (property_exists($data, 'isCustomerPricelist')) { |
||
| 60 | $object->setIsCustomerPricelist($data->{'isCustomerPricelist'}); |
||
| 61 | } |
||
| 62 | if (property_exists($data, 'isCountryPricelist')) { |
||
| 63 | $object->setIsCountryPricelist($data->{'isCountryPricelist'}); |
||
| 64 | } |
||
| 65 | return $object; |
||
| 66 | } |
||
| 106 | } |