| Conditions | 18 |
| Paths | > 20000 |
| Total Lines | 56 |
| Code Lines | 37 |
| 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 |
||
| 85 | public function normalize($object, $format = null, array $context = array()) |
||
| 86 | { |
||
| 87 | $data = new \stdClass(); |
||
| 88 | if (null !== $object->getName()) { |
||
| 89 | $data->{'name'} = $object->getName(); |
||
| 90 | } |
||
| 91 | if (null !== $object->getIdCode()) { |
||
| 92 | $data->{'idCode'} = $object->getIdCode(); |
||
| 93 | } |
||
| 94 | if (null !== $object->getStatus()) { |
||
| 95 | $data->{'status'} = $object->getStatus(); |
||
| 96 | } |
||
| 97 | if (null !== $object->getDefaultLangCode()) { |
||
| 98 | $data->{'defaultLangCode'} = $object->getDefaultLangCode(); |
||
| 99 | } |
||
| 100 | if (null !== $object->getActiveLangCodes()) { |
||
| 101 | $values = array(); |
||
| 102 | foreach ($object->getActiveLangCodes() as $value) { |
||
| 103 | $values[] = $value; |
||
| 104 | } |
||
| 105 | $data->{'activeLangCodes'} = $values; |
||
| 106 | } |
||
| 107 | if (null !== $object->getBaseCurrency()) { |
||
| 108 | $data->{'baseCurrency'} = $object->getBaseCurrency(); |
||
| 109 | } |
||
| 110 | if (null !== $object->getDefaultCustomerCountryCode()) { |
||
| 111 | $data->{'defaultCustomerCountryCode'} = $object->getDefaultCustomerCountryCode(); |
||
| 112 | } |
||
| 113 | if (null !== $object->getGeneralDefaultVatRate()) { |
||
| 114 | $data->{'generalDefaultVatRate'} = $object->getGeneralDefaultVatRate(); |
||
| 115 | } |
||
| 116 | if (null !== $object->getShopCompanyName()) { |
||
| 117 | $data->{'shopCompanyName'} = $object->getShopCompanyName(); |
||
| 118 | } |
||
| 119 | if (null !== $object->getShopAddress()) { |
||
| 120 | $data->{'shopAddress'} = $object->getShopAddress(); |
||
| 121 | } |
||
| 122 | if (null !== $object->getShopPostalCode()) { |
||
| 123 | $data->{'shopPostalCode'} = $object->getShopPostalCode(); |
||
| 124 | } |
||
| 125 | if (null !== $object->getShopCity()) { |
||
| 126 | $data->{'shopCity'} = $object->getShopCity(); |
||
| 127 | } |
||
| 128 | if (null !== $object->getShopOrgNo()) { |
||
| 129 | $data->{'shopOrgNo'} = $object->getShopOrgNo(); |
||
| 130 | } |
||
| 131 | if (null !== $object->getShopPhoneNo()) { |
||
| 132 | $data->{'shopPhoneNo'} = $object->getShopPhoneNo(); |
||
| 133 | } |
||
| 134 | if (null !== $object->getShopVatNo()) { |
||
| 135 | $data->{'shopVatNo'} = $object->getShopVatNo(); |
||
| 136 | } |
||
| 137 | if (null !== $object->getShopCountryCode()) { |
||
| 138 | $data->{'shopCountryCode'} = $object->getShopCountryCode(); |
||
| 139 | } |
||
| 140 | return $data; |
||
| 141 | } |
||
| 142 | } |