Conditions | 10 |
Paths | 57 |
Total Lines | 73 |
Code Lines | 51 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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 |
||
108 | public function createOrderFrontend(array $attributes, $shopId, $noAccountUser) |
||
109 | { |
||
110 | $attributes['shop_id'] = $shopId; |
||
111 | $attributes['client_id'] = $attributes['user_id']; |
||
112 | $client = ClientService::selectOneByShopIdAndId($shopId, $attributes['user_id']); |
||
113 | |||
114 | $this->repo->getModel()->fill($attributes); |
||
115 | $this->repo->getModel()->save(); |
||
116 | |||
117 | if (!Cart::getContent()->count()) { |
||
118 | return false; |
||
119 | } |
||
120 | |||
121 | $this->addProducts($this->repo->getModel(), Cart::getContent()); |
||
122 | |||
123 | if ($client) { |
||
124 | if ($client->clientDeliveryAddress) { |
||
125 | $deliveryOrderAddress = $this->createAddress($client->clientDeliveryAddress->toArray(), $this->repo->getModel()->id); |
||
126 | } |
||
127 | |||
128 | if ($client->clientBillAddress) { |
||
129 | $billOrderAddress = $this->createAddress($client->clientBillAddress->toArray(), $this->repo->getModel()->id); |
||
130 | } |
||
131 | |||
132 | $this->repo->getModel()->fill(array('delivery_order_address_id' => $deliveryOrderAddress->id, 'bill_order_address_id' => $billOrderAddress->id)); |
||
133 | $this->repo->getModel()->save(); |
||
134 | |||
135 | } elseif ($noAccountUser) { |
||
136 | if (isset($noAccountUser['delivery'])) { |
||
137 | $deliveryOrderAddress = $billOrderAddress = $this->createAddress($noAccountUser['delivery'], $this->repo->getModel()->id); |
||
138 | } else { |
||
139 | $deliveryOrderAddress = $billOrderAddress = $this->createAddress($noAccountUser, $this->repo->getModel()->id); |
||
140 | } |
||
141 | |||
142 | $billOrderAddress = $billOrderAddress = $this->createAddress($noAccountUser, $this->repo->getModel()->id); |
||
143 | $this->repo->getModel()->fill(array('delivery_order_address_id' => $deliveryOrderAddress->id, 'bill_order_address_id' => $billOrderAddress->id)); |
||
144 | $this->repo->getModel()->save(); |
||
145 | } |
||
146 | |||
147 | if (Cart::getConditionsByType('sending_method')->count()) { |
||
148 | $attributes = Cart::getConditionsByType('sending_method')->first()->getAttributes(); |
||
149 | $sendingMethod = SendingMethodService::find($attributes['data']['id']); |
||
150 | $price = $sendingMethod->getPriceDetails(); |
||
151 | $sendingMethodArray = $sendingMethod->toArray(); |
||
152 | $sendingMethodArray['price_with_tax'] = Cart::getConditionsByType('sending_method')->first()->getAttributes()['data']['price_details']['original_price_inc_tax']; |
||
153 | $sendingMethodArray['price_without_tax'] = Cart::getConditionsByType('sending_method')->first()->getAttributes()['data']['price_details']['original_price_ex_tax']; |
||
154 | $sendingMethodArray['tax_rate'] = $price['tax_rate']; |
||
155 | $sendingMethodArray['sending_method_id'] = $sendingMethod->id; |
||
156 | $sendingMethodArray['order_id'] = $this->repo->getModel()->id; |
||
157 | $orderSendingMethod = $this->getSendingMethodModel()->fill($sendingMethodArray); |
||
158 | $orderSendingMethod = $orderSendingMethod->save(); |
||
159 | } |
||
160 | |||
161 | if (Cart::getConditionsByType('payment_method')->count()) { |
||
162 | $attributes = Cart::getConditionsByType('payment_method')->first()->getAttributes(); |
||
163 | $paymentMethod = PaymentMethodService::find($attributes['data']['id']); |
||
164 | $price = $paymentMethod->getPriceDetails(); |
||
165 | $paymentMethodArray = $paymentMethod->toArray(); |
||
166 | $paymentMethodArray['price_with_tax'] = Cart::getConditionsByType('payment_method')->first()->getAttributes()['data']['value_inc_tax']; |
||
167 | $paymentMethodArray['price_without_tax'] = Cart::getConditionsByType('payment_method')->first()->getAttributes()['data']['value_ex_tax']; |
||
168 | $paymentMethodArray['tax_rate'] = $price['tax_rate']; |
||
169 | $paymentMethodArray['payment_method_id'] = $paymentMethod->id; |
||
170 | $paymentMethodArray['order_id'] = $this->repo->getModel()->id; |
||
171 | $orderPaymentMethod = $this->getPaymentMethodModel()->fill($paymentMethodArray); |
||
172 | $orderPaymentMethod = $orderPaymentMethod->save(); |
||
173 | } |
||
174 | |||
175 | if ($this->repo->getModel()->orderPaymentMethod->paymentMethod->order_confirmed_order_status_id) { |
||
176 | $this->repo->getModel()->fill(array('order_status_id' => $this->repo->getModel()->orderPaymentMethod->paymentMethod->order_confirmed_order_status_id)); |
||
177 | $this->repo->getModel()->save(); |
||
178 | } |
||
179 | |||
180 | return $this->repo->getModel(); |
||
181 | } |
||
215 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths