Conditions | 26 |
Paths | > 20000 |
Total Lines | 92 |
Code Lines | 65 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
131 | public function normalize($object, $format = null, array $context = array()) |
||
132 | { |
||
133 | $data = new \stdClass(); |
||
134 | if (null !== $object->getProductId()) { |
||
135 | $data->{'productId'} = $object->getProductId(); |
||
136 | } |
||
137 | if (null !== $object->getCreatedAt()) { |
||
138 | $data->{'createdAt'} = $object->getCreatedAt(); |
||
139 | } |
||
140 | $data->{'defaultVatRate'} = $object->getDefaultVatRate(); |
||
141 | if (null !== $object->getVisibility()) { |
||
142 | $data->{'visibility'} = $object->getVisibility(); |
||
143 | } |
||
144 | if (null !== $object->getVisibilityPricelistIds()) { |
||
145 | $values = array(); |
||
146 | foreach ($object->getVisibilityPricelistIds() as $value) { |
||
147 | $values[] = $value; |
||
148 | } |
||
149 | $data->{'visibilityPricelistIds'} = $values; |
||
150 | } |
||
151 | if (null !== $object->getMoreInfoUrl()) { |
||
152 | $data->{'moreInfoUrl'} = $object->getMoreInfoUrl(); |
||
153 | } |
||
154 | $data->{'manufacturerId'} = $object->getManufacturerId(); |
||
155 | $data->{'unitId'} = $object->getUnitId(); |
||
156 | $data->{'sortIndex'} = $object->getSortIndex(); |
||
157 | if (null !== $object->getType()) { |
||
158 | $data->{'type'} = $object->getType(); |
||
159 | } |
||
160 | if (null !== $object->getIsBackInStockWatchable()) { |
||
161 | $data->{'isBackInStockWatchable'} = $object->getIsBackInStockWatchable(); |
||
162 | } |
||
163 | if (null !== $object->getBundleUseManualPrice()) { |
||
164 | $data->{'bundleUseManualPrice'} = $object->getBundleUseManualPrice(); |
||
165 | } |
||
166 | $data->{'accounting'} = $object->getAccounting(); |
||
167 | if (null !== $object->getHasSeveralVariants()) { |
||
168 | $data->{'hasSeveralVariants'} = $object->getHasSeveralVariants(); |
||
169 | } |
||
170 | if (null !== $object->getModifiedAt()) { |
||
171 | $data->{'modifiedAt'} = $object->getModifiedAt(); |
||
172 | } |
||
173 | if (null !== $object->getVariants()) { |
||
174 | $values_1 = array(); |
||
175 | foreach ($object->getVariants() as $value_1) { |
||
176 | $values_1[] = $this->normalizer->normalize($value_1, 'json', $context); |
||
177 | } |
||
178 | $data->{'variants'} = $values_1; |
||
179 | } |
||
180 | if (null !== $object->getBundledProducts()) { |
||
181 | $values_2 = array(); |
||
182 | foreach ($object->getBundledProducts() as $value_2) { |
||
183 | $values_2[] = $this->normalizer->normalize($value_2, 'json', $context); |
||
184 | } |
||
185 | $data->{'bundledProducts'} = $values_2; |
||
186 | } |
||
187 | if (null !== $object->getMediaFiles()) { |
||
188 | $values_3 = array(); |
||
189 | foreach ($object->getMediaFiles() as $value_3) { |
||
190 | $values_3[] = $this->normalizer->normalize($value_3, 'json', $context); |
||
191 | } |
||
192 | $data->{'mediaFiles'} = $values_3; |
||
193 | } |
||
194 | if (null !== $object->getLanguages()) { |
||
195 | $values_4 = array(); |
||
196 | foreach ($object->getLanguages() as $value_4) { |
||
197 | $values_4[] = $this->normalizer->normalize($value_4, 'json', $context); |
||
198 | } |
||
199 | $data->{'languages'} = $values_4; |
||
200 | } |
||
201 | if (null !== $object->getVatRates()) { |
||
202 | $values_5 = array(); |
||
203 | foreach ($object->getVatRates() as $value_5) { |
||
204 | $values_5[] = $this->normalizer->normalize($value_5, 'json', $context); |
||
205 | } |
||
206 | $data->{'vatRates'} = $values_5; |
||
207 | } |
||
208 | if (null !== $object->getCategories()) { |
||
209 | $values_6 = array(); |
||
210 | foreach ($object->getCategories() as $value_6) { |
||
211 | $values_6[] = $this->normalizer->normalize($value_6, 'json', $context); |
||
212 | } |
||
213 | $data->{'categories'} = $values_6; |
||
214 | } |
||
215 | if (null !== $object->getMetaData()) { |
||
216 | $values_7 = array(); |
||
217 | foreach ($object->getMetaData() as $value_7) { |
||
218 | $values_7[] = $this->normalizer->normalize($value_7, 'json', $context); |
||
219 | } |
||
220 | $data->{'metaData'} = $values_7; |
||
221 | } |
||
222 | return $data; |
||
223 | } |
||
224 | } |