| Conditions | 19 |
| Paths | > 20000 |
| Total Lines | 59 |
| Code Lines | 39 |
| 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\ShopModel(); |
||
| 31 | if (property_exists($data, 'name')) { |
||
| 32 | $object->setName($data->{'name'}); |
||
| 33 | } |
||
| 34 | if (property_exists($data, 'idCode')) { |
||
| 35 | $object->setIdCode($data->{'idCode'}); |
||
| 36 | } |
||
| 37 | if (property_exists($data, 'status')) { |
||
| 38 | $object->setStatus($data->{'status'}); |
||
| 39 | } |
||
| 40 | if (property_exists($data, 'defaultLangCode')) { |
||
| 41 | $object->setDefaultLangCode($data->{'defaultLangCode'}); |
||
| 42 | } |
||
| 43 | if (property_exists($data, 'activeLangCodes')) { |
||
| 44 | $values = array(); |
||
| 45 | foreach ($data->{'activeLangCodes'} as $value) { |
||
| 46 | $values[] = $value; |
||
| 47 | } |
||
| 48 | $object->setActiveLangCodes($values); |
||
| 49 | } |
||
| 50 | if (property_exists($data, 'baseCurrency')) { |
||
| 51 | $object->setBaseCurrency($data->{'baseCurrency'}); |
||
| 52 | } |
||
| 53 | if (property_exists($data, 'defaultCustomerCountryCode')) { |
||
| 54 | $object->setDefaultCustomerCountryCode($data->{'defaultCustomerCountryCode'}); |
||
| 55 | } |
||
| 56 | if (property_exists($data, 'generalDefaultVatRate')) { |
||
| 57 | $object->setGeneralDefaultVatRate($data->{'generalDefaultVatRate'}); |
||
| 58 | } |
||
| 59 | if (property_exists($data, 'shopCompanyName')) { |
||
| 60 | $object->setShopCompanyName($data->{'shopCompanyName'}); |
||
| 61 | } |
||
| 62 | if (property_exists($data, 'shopAddress')) { |
||
| 63 | $object->setShopAddress($data->{'shopAddress'}); |
||
| 64 | } |
||
| 65 | if (property_exists($data, 'shopPostalCode')) { |
||
| 66 | $object->setShopPostalCode($data->{'shopPostalCode'}); |
||
| 67 | } |
||
| 68 | if (property_exists($data, 'shopCity')) { |
||
| 69 | $object->setShopCity($data->{'shopCity'}); |
||
| 70 | } |
||
| 71 | if (property_exists($data, 'shopOrgNo')) { |
||
| 72 | $object->setShopOrgNo($data->{'shopOrgNo'}); |
||
| 73 | } |
||
| 74 | if (property_exists($data, 'shopPhoneNo')) { |
||
| 75 | $object->setShopPhoneNo($data->{'shopPhoneNo'}); |
||
| 76 | } |
||
| 77 | if (property_exists($data, 'shopVatNo')) { |
||
| 78 | $object->setShopVatNo($data->{'shopVatNo'}); |
||
| 79 | } |
||
| 80 | if (property_exists($data, 'shopCountryCode')) { |
||
| 81 | $object->setShopCountryCode($data->{'shopCountryCode'}); |
||
| 82 | } |
||
| 83 | return $object; |
||
| 84 | } |
||
| 142 | } |