Conditions | 54 |
Total Lines | 164 |
Code Lines | 109 |
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\OrderUpdateModel(); |
||
31 | if (property_exists($data, 'orderId')) { |
||
32 | $object->setOrderId($data->{'orderId'}); |
||
33 | } |
||
34 | if (property_exists($data, 'modifiedAt')) { |
||
35 | $object->setModifiedAt($data->{'modifiedAt'}); |
||
36 | } |
||
37 | if (property_exists($data, 'baseCurrencyCode')) { |
||
38 | $object->setBaseCurrencyCode($data->{'baseCurrencyCode'}); |
||
39 | } |
||
40 | if (property_exists($data, 'shopCountryCode')) { |
||
41 | $object->setShopCountryCode($data->{'shopCountryCode'}); |
||
42 | } |
||
43 | if (property_exists($data, 'totalAmount')) { |
||
44 | $object->setTotalAmount($data->{'totalAmount'}); |
||
45 | } |
||
46 | if (property_exists($data, 'totalVat')) { |
||
47 | $object->setTotalVat($data->{'totalVat'}); |
||
48 | } |
||
49 | if (property_exists($data, 'amountToPay')) { |
||
50 | $object->setAmountToPay($data->{'amountToPay'}); |
||
51 | } |
||
52 | if (property_exists($data, 'totalAmountInBaseCurrency')) { |
||
53 | $object->setTotalAmountInBaseCurrency($data->{'totalAmountInBaseCurrency'}); |
||
54 | } |
||
55 | if (property_exists($data, 'totalVatInBaseCurrency')) { |
||
56 | $object->setTotalVatInBaseCurrency($data->{'totalVatInBaseCurrency'}); |
||
57 | } |
||
58 | if (property_exists($data, 'amountToPayInBaseCurrency')) { |
||
59 | $object->setAmountToPayInBaseCurrency($data->{'amountToPayInBaseCurrency'}); |
||
60 | } |
||
61 | if (property_exists($data, 'createdAt')) { |
||
62 | $object->setCreatedAt($data->{'createdAt'}); |
||
63 | } |
||
64 | if (property_exists($data, 'customerId')) { |
||
65 | $object->setCustomerId($data->{'customerId'}); |
||
66 | } |
||
67 | if (property_exists($data, 'statusId')) { |
||
68 | $object->setStatusId($data->{'statusId'}); |
||
69 | } |
||
70 | if (property_exists($data, 'onOrderStatusChangeSendEmail')) { |
||
71 | $object->setOnOrderStatusChangeSendEmail($data->{'onOrderStatusChangeSendEmail'}); |
||
72 | } |
||
73 | if (property_exists($data, 'onOrderStatusChangeProcessPayment')) { |
||
74 | $object->setOnOrderStatusChangeProcessPayment($data->{'onOrderStatusChangeProcessPayment'}); |
||
75 | } |
||
76 | if (property_exists($data, 'shippingMethodId')) { |
||
77 | $object->setShippingMethodId($data->{'shippingMethodId'}); |
||
78 | } |
||
79 | if (property_exists($data, 'paymentMethodId')) { |
||
80 | $object->setPaymentMethodId($data->{'paymentMethodId'}); |
||
81 | } |
||
82 | if (property_exists($data, 'paymentMethodIdCode')) { |
||
83 | $object->setPaymentMethodIdCode($data->{'paymentMethodIdCode'}); |
||
84 | } |
||
85 | if (property_exists($data, 'paymentMethodName')) { |
||
86 | $object->setPaymentMethodName($data->{'paymentMethodName'}); |
||
87 | } |
||
88 | if (property_exists($data, 'paymentFee')) { |
||
89 | $object->setPaymentFee($data->{'paymentFee'}); |
||
90 | } |
||
91 | if (property_exists($data, 'paymentVatRate')) { |
||
92 | $object->setPaymentVatRate($data->{'paymentVatRate'}); |
||
93 | } |
||
94 | if (property_exists($data, 'shippingMethodName')) { |
||
95 | $object->setShippingMethodName($data->{'shippingMethodName'}); |
||
96 | } |
||
97 | if (property_exists($data, 'shippingCost')) { |
||
98 | $object->setShippingCost($data->{'shippingCost'}); |
||
99 | } |
||
100 | if (property_exists($data, 'shippingVatRate')) { |
||
101 | $object->setShippingVatRate($data->{'shippingVatRate'}); |
||
102 | } |
||
103 | if (property_exists($data, 'totalWeight')) { |
||
104 | $object->setTotalWeight($data->{'totalWeight'}); |
||
105 | } |
||
106 | if (property_exists($data, 'customInfo1')) { |
||
107 | $object->setCustomInfo1($data->{'customInfo1'}); |
||
108 | } |
||
109 | if (property_exists($data, 'customInfo2')) { |
||
110 | $object->setCustomInfo2($data->{'customInfo2'}); |
||
111 | } |
||
112 | if (property_exists($data, 'customInfo3')) { |
||
113 | $object->setCustomInfo3($data->{'customInfo3'}); |
||
114 | } |
||
115 | if (property_exists($data, 'customInfo4')) { |
||
116 | $object->setCustomInfo4($data->{'customInfo4'}); |
||
117 | } |
||
118 | if (property_exists($data, 'discountCode')) { |
||
119 | $object->setDiscountCode($data->{'discountCode'}); |
||
120 | } |
||
121 | if (property_exists($data, 'amountPaid')) { |
||
122 | $object->setAmountPaid($data->{'amountPaid'}); |
||
123 | } |
||
124 | if (property_exists($data, 'amountPaidInBaseCurrency')) { |
||
125 | $object->setAmountPaidInBaseCurrency($data->{'amountPaidInBaseCurrency'}); |
||
126 | } |
||
127 | if (property_exists($data, 'isComplete')) { |
||
128 | $object->setIsComplete($data->{'isComplete'}); |
||
129 | } |
||
130 | if (property_exists($data, 'currencyCode')) { |
||
131 | $object->setCurrencyCode($data->{'currencyCode'}); |
||
132 | } |
||
133 | if (property_exists($data, 'currencyExchangeRate')) { |
||
134 | $object->setCurrencyExchangeRate($data->{'currencyExchangeRate'}); |
||
135 | } |
||
136 | if (property_exists($data, 'currencyPrecision')) { |
||
137 | $object->setCurrencyPrecision($data->{'currencyPrecision'}); |
||
138 | } |
||
139 | if (property_exists($data, 'langCode')) { |
||
140 | $object->setLangCode($data->{'langCode'}); |
||
141 | } |
||
142 | if (property_exists($data, 'paymentReference')) { |
||
143 | $object->setPaymentReference($data->{'paymentReference'}); |
||
144 | } |
||
145 | if (property_exists($data, 'paymentStatus')) { |
||
146 | $object->setPaymentStatus($data->{'paymentStatus'}); |
||
147 | } |
||
148 | if (property_exists($data, 'isRead')) { |
||
149 | $object->setIsRead($data->{'isRead'}); |
||
150 | } |
||
151 | if (property_exists($data, 'hasComment')) { |
||
152 | $object->setHasComment($data->{'hasComment'}); |
||
153 | } |
||
154 | if (property_exists($data, 'internalComment')) { |
||
155 | $object->setInternalComment($data->{'internalComment'}); |
||
156 | } |
||
157 | if (property_exists($data, 'shippingTrackerType')) { |
||
158 | $object->setShippingTrackerType($data->{'shippingTrackerType'}); |
||
159 | } |
||
160 | if (property_exists($data, 'shippingTrackingNo')) { |
||
161 | $object->setShippingTrackingNo($data->{'shippingTrackingNo'}); |
||
162 | } |
||
163 | if (property_exists($data, 'originalCustomerEmail')) { |
||
164 | $object->setOriginalCustomerEmail($data->{'originalCustomerEmail'}); |
||
165 | } |
||
166 | if (property_exists($data, 'originalCustomerNationalIdNo')) { |
||
167 | $object->setOriginalCustomerNationalIdNo($data->{'originalCustomerNationalIdNo'}); |
||
168 | } |
||
169 | if (property_exists($data, 'originalCustomerVatNo')) { |
||
170 | $object->setOriginalCustomerVatNo($data->{'originalCustomerVatNo'}); |
||
171 | } |
||
172 | if (property_exists($data, 'originalCustomerCustomInfo1')) { |
||
173 | $object->setOriginalCustomerCustomInfo1($data->{'originalCustomerCustomInfo1'}); |
||
174 | } |
||
175 | if (property_exists($data, 'originalCustomerCustomInfo2')) { |
||
176 | $object->setOriginalCustomerCustomInfo2($data->{'originalCustomerCustomInfo2'}); |
||
177 | } |
||
178 | if (property_exists($data, 'items')) { |
||
179 | $values = array(); |
||
180 | foreach ($data->{'items'} as $value) { |
||
181 | $values[] = $this->denormalizer->denormalize($value, 'Starweb\\Api\\Generated\\Model\\OrderItemModel', 'json', $context); |
||
182 | } |
||
183 | $object->setItems($values); |
||
184 | } |
||
185 | if (property_exists($data, 'addresses')) { |
||
186 | $object->setAddresses($this->denormalizer->denormalize($data->{'addresses'}, 'Starweb\\Api\\Generated\\Model\\OrderAddressModel', 'json', $context)); |
||
|
|||
187 | } |
||
188 | return $object; |
||
189 | } |
||
352 | } |