| Conditions | 3 |
| Paths | 4 |
| Total Lines | 76 |
| Code Lines | 63 |
| 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 |
||
| 91 | protected function getPayload(OrderTransfer $orderTransfer): array |
||
| 92 | { |
||
| 93 | $locale = $orderTransfer->getCustomer()->getLocale() ? |
||
| 94 | $orderTransfer->getCustomer()->getLocale()->getLocaleName() : |
||
| 95 | $this->localeFacade->getCurrentLocaleName(); |
||
| 96 | |||
| 97 | $payload = [ |
||
| 98 | 'Customer' => [ |
||
| 99 | 'Mail' => $orderTransfer->getCustomer()->getEmail(), |
||
| 100 | 'Salutation' => $orderTransfer->getCustomer()->getSalutation(), |
||
| 101 | 'Firstname' => $orderTransfer->getCustomer()->getFirstName(), |
||
| 102 | 'Lastname' => $orderTransfer->getCustomer()->getLastName(), |
||
| 103 | 'Id' => $orderTransfer->getCustomer()->getIdCustomer(), |
||
| 104 | 'Language' => $locale, |
||
| 105 | ], |
||
| 106 | 'Billing' => [ |
||
| 107 | 'Salutation' => $orderTransfer->getBillingAddress()->getSalutation(), |
||
| 108 | 'Firstname' => $orderTransfer->getBillingAddress()->getFirstName(), |
||
| 109 | 'Lastname' => $orderTransfer->getBillingAddress()->getLastName(), |
||
| 110 | 'Company' => $orderTransfer->getBillingAddress()->getCompany(), |
||
| 111 | 'Address1' => $orderTransfer->getBillingAddress()->getAddress1(), |
||
| 112 | 'Address2' => $orderTransfer->getBillingAddress()->getAddress2(), |
||
| 113 | 'Address3' => $orderTransfer->getBillingAddress()->getAddress3(), |
||
| 114 | 'City' => $orderTransfer->getBillingAddress()->getCity(), |
||
| 115 | 'Zip' => $orderTransfer->getBillingAddress()->getZipCode(), |
||
| 116 | 'Country' => $orderTransfer->getBillingAddress()->getCountry()->getName(), |
||
| 117 | ], |
||
| 118 | 'Shipping' => [ |
||
| 119 | 'Salutation' => $orderTransfer->getShippingAddress()->getSalutation(), |
||
| 120 | 'Firstname' => $orderTransfer->getShippingAddress()->getFirstName(), |
||
| 121 | 'Lastname' => $orderTransfer->getShippingAddress()->getLastName(), |
||
| 122 | 'Company' => $orderTransfer->getShippingAddress()->getCompany(), |
||
| 123 | 'Address1' => $orderTransfer->getShippingAddress()->getAddress1(), |
||
| 124 | 'Address2' => $orderTransfer->getShippingAddress()->getAddress2(), |
||
| 125 | 'Address3' => $orderTransfer->getShippingAddress()->getAddress3(), |
||
| 126 | 'City' => $orderTransfer->getShippingAddress()->getCity(), |
||
| 127 | 'Zip' => $orderTransfer->getShippingAddress()->getZipCode(), |
||
| 128 | 'Country' => $orderTransfer->getShippingAddress()->getCountry()->getName(), |
||
| 129 | ], |
||
| 130 | 'Order' => [ |
||
| 131 | 'Number' => $orderTransfer->getIdSalesOrder(), |
||
| 132 | 'Comment' => $orderTransfer->getCartNote(), |
||
| 133 | 'CancelComment' => '', |
||
| 134 | 'OrderDate' => $this->dateTimeService->formatDateTime($orderTransfer->getCreatedAt()), |
||
| 135 | 'SubTotal' => $this->getFormattedPriceFromInt($orderTransfer->getTotals()->getSubtotal()), |
||
| 136 | 'Discount' => $this->getFormattedPriceFromInt($orderTransfer->getTotals()->getDiscountTotal()), |
||
| 137 | 'Tax' => $this->getFormattedPriceFromInt($orderTransfer->getTotals()->getTaxTotal()->getAmount()), |
||
| 138 | 'GrandTotal' => $this->getFormattedPriceFromInt($orderTransfer->getTotals()->getGrandTotal()), |
||
| 139 | 'TotalDeliveryCosts' => $this->getDeliveryCosts($orderTransfer->getExpenses()), |
||
| 140 | 'TotalPaymentCosts' => $this->getPaymentMethodsTotal($orderTransfer->getPayments()), |
||
| 141 | ], |
||
| 142 | 'Payment' => $this->getPaymentMethodInfo($orderTransfer->getPayments()), |
||
| 143 | 'Delivery' => $this->getOrderDeliveryInfo($orderTransfer->getShipmentMethods(), $orderTransfer->getExpenses()), |
||
| 144 | 'Shop' => [ |
||
| 145 | 'ShopLocale' => $this->localeFacade->getCurrentLocaleName(), |
||
| 146 | 'ShopUrl' => $this->config->getHostYves(), |
||
| 147 | ], |
||
| 148 | ]; |
||
| 149 | |||
| 150 | foreach ($orderTransfer->getItems() as $item) { |
||
| 151 | $payload['OrderItem'][] = [ |
||
| 152 | 'Name' => $item->getName(), |
||
| 153 | 'Sku' => $item->getSku(), |
||
| 154 | 'Image' => $this->getItemImageLink($item->getImages()), |
||
| 155 | 'DeepLink' => $this->getDeepLink($item, $locale), |
||
| 156 | 'Price' => $this->getFormattedPriceFromInt($item->getRefundableAmount()), |
||
| 157 | 'Quantity' => $item->getQuantity(), |
||
| 158 | 'Sum' => $this->getFormattedPriceFromInt($item->getSumPriceToPayAggregation()), |
||
| 159 | 'OriginalPrice' => $this->getFormattedPriceFromInt($item->getUnitPrice()), |
||
| 160 | 'TaxAmount' => $this->getFormattedPriceFromInt($item->getUnitTaxAmount()), |
||
| 161 | 'TaxRate' => $item->getTaxRate(), |
||
| 162 | 'Discount' => $this->getFormattedPriceFromInt($item->getUnitDiscountAmountAggregation()), |
||
| 163 | ]; |
||
| 164 | } |
||
| 165 | |||
| 166 | return $payload; |
||
| 167 | } |
||
| 306 |
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