Conditions | 14 |
Paths | 13 |
Total Lines | 86 |
Code Lines | 54 |
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 |
||
68 | public function generateInvoiceFromOrder($orderId) |
||
69 | { |
||
70 | $order = $this->order->find($orderId); |
||
71 | |||
72 | if ($order->count()) { |
||
73 | $attributes = $order->toArray(); |
||
74 | $attributes['order_id'] = $order->id; |
||
75 | |||
76 | $validator = Validator::make($attributes, $this->rules()); |
||
77 | |||
78 | if ($validator->fails()) { |
||
79 | return $validator; |
||
80 | } |
||
81 | |||
82 | $this->model->fill($attributes); |
||
83 | $this->model->save(); |
||
84 | |||
85 | if ($this->model->id) { |
||
86 | if ($order->products) { |
||
87 | foreach ($order->products as $product) { |
||
88 | $product = $product->toArray(); |
||
89 | $product['product_id'] = $product['product_id']; |
||
90 | |||
91 | if (isset($product['product_combination_id'])) { |
||
92 | $product['product_attribute_id'] = $product['product_combination_id']; |
||
93 | $productCombinationTitleArray = array(); |
||
94 | if (isset($product['product_combination_title']) and is_array($product['product_combination_title'])) { |
||
95 | foreach ($product['product_combination_title'] as $key => $val) { |
||
96 | $productCombinationTitle[] = $key.': '.$val; |
||
97 | } |
||
98 | |||
99 | $product['product_attribute_title'] = implode(', ', $productCombinationTitle); |
||
100 | } |
||
101 | } |
||
102 | |||
103 | $products[] = new InvoiceRule($product); |
||
104 | } |
||
105 | |||
106 | if ($order->orderSendingMethod) { |
||
107 | $invoiceRule = array( |
||
108 | 'type' => 'sending_cost', |
||
109 | 'title' => $order->orderSendingMethod->title, |
||
110 | 'tax_rate_id' => $order->orderSendingMethod->tax_rate_id, |
||
111 | 'tax_rate' => $order->orderSendingMethod->tax_rate, |
||
112 | 'amount' => 1, |
||
113 | 'price_with_tax' => $order->orderSendingMethod->price_with_tax, |
||
114 | 'price_without_tax' => $order->orderSendingMethod->price_without_tax, |
||
115 | 'total_price_with_tax' => $order->orderSendingMethod->price_with_tax, |
||
116 | 'total_price_without_tax' => $order->orderSendingMethod->price_without_tax, |
||
117 | ); |
||
118 | |||
119 | $products[] = new InvoiceRule($invoiceRule); |
||
120 | } |
||
121 | |||
122 | if ($order->orderPaymentMethod) { |
||
123 | $invoiceRule = array( |
||
124 | 'type' => 'payment_cost', |
||
125 | 'title' => $order->orderPaymentMethod->title, |
||
126 | 'tax_rate_id' => $order->orderPaymentMethod->tax_rate_id, |
||
127 | 'tax_rate' => $order->orderPaymentMethod->tax_rate, |
||
128 | 'amount' => 1, |
||
129 | 'price_with_tax' => $order->orderPaymentMethod->price_with_tax, |
||
130 | 'price_without_tax' => $order->orderPaymentMethod->price_without_tax, |
||
131 | 'total_price_with_tax' => $order->orderPaymentMethod->price_with_tax, |
||
132 | 'total_price_without_tax' => $order->orderPaymentMethod->price_without_tax, |
||
133 | ); |
||
134 | |||
135 | $products[] = new InvoiceRule($invoiceRule); |
||
136 | } |
||
137 | |||
138 | $this->model->products()->saveMany($products); |
||
139 | } |
||
140 | |||
141 | if ($order->orderBillAddress and $order->orderDeliveryAddress) { |
||
142 | $deliveryInvoiceAddress = new InvoiceAddress($order->orderBillAddress->toArray()); |
||
143 | |||
144 | $billInvoiceAddress = new InvoiceAddress($order->orderDeliveryAddress->toArray()); |
||
145 | |||
146 | $this->model->invoiceAddress()->saveMany(array($deliveryInvoiceAddress, $billInvoiceAddress)); |
||
147 | |||
148 | $this->model->fill(array('delivery_invoice_address_id' => $deliveryInvoiceAddress->id, 'bill_invoice_address_id' => $billInvoiceAddress->id)); |
||
149 | $this->model->save(); |
||
150 | } |
||
151 | } |
||
152 | |||
153 | return $this->model; |
||
154 | } |
||
172 |
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