Conditions | 12 |
Paths | 1024 |
Total Lines | 38 |
Code Lines | 25 |
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 |
||
67 | public function normalize($object, $format = null, array $context = array()) |
||
68 | { |
||
69 | $data = new \stdClass(); |
||
70 | if (null !== $object->getPricelistId()) { |
||
71 | $data->{'pricelistId'} = $object->getPricelistId(); |
||
72 | } |
||
73 | if (null !== $object->getName()) { |
||
74 | $data->{'name'} = $object->getName(); |
||
75 | } |
||
76 | if (null !== $object->getIsMaster()) { |
||
77 | $data->{'isMaster'} = $object->getIsMaster(); |
||
78 | } |
||
79 | if (null !== $object->getIsActive()) { |
||
80 | $data->{'isActive'} = $object->getIsActive(); |
||
81 | } |
||
82 | if (null !== $object->getRegion()) { |
||
83 | $data->{'region'} = $object->getRegion(); |
||
84 | } |
||
85 | if (null !== $object->getCountryCodes()) { |
||
86 | $values = array(); |
||
87 | foreach ($object->getCountryCodes() as $value) { |
||
88 | $values[] = $value; |
||
89 | } |
||
90 | $data->{'countryCodes'} = $values; |
||
91 | } |
||
92 | if (null !== $object->getCurrencyCode()) { |
||
93 | $data->{'currencyCode'} = $object->getCurrencyCode(); |
||
94 | } |
||
95 | if (null !== $object->getParentPricelistId()) { |
||
96 | $data->{'parentPricelistId'} = $object->getParentPricelistId(); |
||
97 | } |
||
98 | if (null !== $object->getIsCustomerPricelist()) { |
||
99 | $data->{'isCustomerPricelist'} = $object->getIsCustomerPricelist(); |
||
100 | } |
||
101 | if (null !== $object->getIsCountryPricelist()) { |
||
102 | $data->{'isCountryPricelist'} = $object->getIsCountryPricelist(); |
||
103 | } |
||
104 | return $data; |
||
105 | } |
||
106 | } |