| Conditions | 1 |
| Paths | 1 |
| Total Lines | 126 |
| Code Lines | 96 |
| 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 declare(strict_types=1); |
||
| 26 | private function getOrderData(string $orderId, Context $context): array |
||
| 27 | { |
||
| 28 | $stateMachineRegistry = $this->getContainer()->get(StateMachineRegistry::class); |
||
| 29 | $orderCustomerId = Uuid::randomHex(); |
||
| 30 | $addressId = Uuid::randomHex(); |
||
| 31 | $orderLineItemId = Uuid::randomHex(); |
||
| 32 | $countryStateId = Uuid::randomHex(); |
||
| 33 | $customerId = Uuid::randomHex(); |
||
| 34 | |||
| 35 | $order = [ |
||
| 36 | [ |
||
| 37 | 'id' => $orderId, |
||
| 38 | 'price' => new CartPrice(10, 10, 10, new CalculatedTaxCollection(), new TaxRuleCollection(), CartPrice::TAX_STATE_NET), |
||
| 39 | 'shippingCosts' => new CalculatedPrice(10, 10, new CalculatedTaxCollection(), new TaxRuleCollection()), |
||
| 40 | 'stateId' => $stateMachineRegistry->getInitialState(OrderStates::STATE_MACHINE, $context)->getId(), |
||
| 41 | 'paymentMethodId' => $this->getValidPaymentMethodId(), |
||
| 42 | 'currencyId' => Defaults::CURRENCY, |
||
| 43 | 'currencyFactor' => 1, |
||
| 44 | 'salesChannelId' => Defaults::SALES_CHANNEL, |
||
| 45 | 'orderDate' => '2019-04-01 08:36:43.267', |
||
| 46 | 'deliveries' => [ |
||
| 47 | [ |
||
| 48 | 'stateId' => $stateMachineRegistry->getInitialState(OrderDeliveryStates::STATE_MACHINE, $context)->getId(), |
||
| 49 | 'shippingMethodId' => $this->getValidShippingMethodId(), |
||
| 50 | 'shippingCosts' => new CalculatedPrice(10, 10, new CalculatedTaxCollection(), new TaxRuleCollection()), |
||
| 51 | 'shippingDateEarliest' => date(DATE_ISO8601), |
||
| 52 | 'shippingDateLatest' => date(DATE_ISO8601), |
||
| 53 | 'shippingOrderAddress' => [ |
||
| 54 | 'salutationId' => $this->getValidSalutationId(), |
||
| 55 | 'firstName' => 'Floy', |
||
| 56 | 'lastName' => 'Glover', |
||
| 57 | 'zipcode' => '59438-0403', |
||
| 58 | 'city' => 'Stellaberg', |
||
| 59 | 'street' => 'street', |
||
| 60 | 'country' => [ |
||
| 61 | 'name' => 'kasachstan', |
||
| 62 | 'id' => $this->getValidCountryId(), |
||
| 63 | ], |
||
| 64 | ], |
||
| 65 | 'positions' => [ |
||
| 66 | [ |
||
| 67 | 'price' => new CalculatedPrice(10, 10, new CalculatedTaxCollection(), new TaxRuleCollection()), |
||
| 68 | 'orderLineItemId' => $orderLineItemId, |
||
| 69 | ], |
||
| 70 | ], |
||
| 71 | ], |
||
| 72 | ], |
||
| 73 | 'lineItems' => [ |
||
| 74 | [ |
||
| 75 | 'id' => $orderLineItemId, |
||
| 76 | 'identifier' => 'test', |
||
| 77 | 'quantity' => 1, |
||
| 78 | 'type' => 'test', |
||
| 79 | 'label' => 'test', |
||
| 80 | 'price' => new CalculatedPrice(10, 10, new CalculatedTaxCollection(), new TaxRuleCollection()), |
||
| 81 | 'priceDefinition' => new QuantityPriceDefinition(10, new TaxRuleCollection(), 2), |
||
| 82 | 'priority' => 100, |
||
| 83 | 'good' => true, |
||
| 84 | ], |
||
| 85 | ], |
||
| 86 | 'deepLinkCode' => 'BwvdEInxOHBbwfRw6oHF1Q_orfYeo9RY', |
||
| 87 | 'orderCustomerId' => $orderCustomerId, |
||
| 88 | 'orderCustomer' => [ |
||
| 89 | 'id' => $orderCustomerId, |
||
| 90 | 'email' => '[email protected]', |
||
| 91 | 'firstName' => 'Noe', |
||
| 92 | 'lastName' => 'Hill', |
||
| 93 | 'salutationId' => $this->getValidSalutationId(), |
||
| 94 | 'title' => 'Doc', |
||
| 95 | 'customerNumber' => 'Test', |
||
| 96 | 'customer' => [ |
||
| 97 | 'id' => $customerId, |
||
| 98 | 'email' => '[email protected]', |
||
| 99 | 'firstName' => 'Noe', |
||
| 100 | 'lastName' => 'Hill', |
||
| 101 | 'salutationId' => $this->getValidSalutationId(), |
||
| 102 | 'title' => 'Doc', |
||
| 103 | 'customerNumber' => 'Test', |
||
| 104 | 'guest' => true, |
||
| 105 | 'group' => ['name' => 'testse2323'], |
||
| 106 | 'defaultPaymentMethodId' => $this->getValidPaymentMethodId(), |
||
| 107 | 'salesChannelId' => Defaults::SALES_CHANNEL, |
||
| 108 | 'defaultBillingAddressId' => $addressId, |
||
| 109 | 'defaultShippingAddressId' => $addressId, |
||
| 110 | 'addresses' => [ |
||
| 111 | [ |
||
| 112 | 'id' => $addressId, |
||
| 113 | 'salutationId' => $this->getValidSalutationId(), |
||
| 114 | 'firstName' => 'Floy', |
||
| 115 | 'lastName' => 'Glover', |
||
| 116 | 'zipcode' => '59438-0403', |
||
| 117 | 'city' => 'Stellaberg', |
||
| 118 | 'street' => 'street', |
||
| 119 | 'countryStateId' => $countryStateId, |
||
| 120 | 'country' => [ |
||
| 121 | 'name' => 'kasachstan', |
||
| 122 | 'id' => $this->getValidCountryId(), |
||
| 123 | 'states' => [ |
||
| 124 | [ |
||
| 125 | 'id' => $countryStateId, |
||
| 126 | 'name' => 'oklahoma', |
||
| 127 | 'shortCode' => 'OH', |
||
| 128 | ], |
||
| 129 | ], |
||
| 130 | ], |
||
| 131 | ], |
||
| 132 | ], |
||
| 133 | ], |
||
| 134 | ], |
||
| 135 | 'billingAddressId' => $addressId, |
||
| 136 | 'addresses' => [ |
||
| 137 | [ |
||
| 138 | 'salutationId' => $this->getValidSalutationId(), |
||
| 139 | 'firstName' => 'Floy', |
||
| 140 | 'lastName' => 'Glover', |
||
| 141 | 'zipcode' => '59438-0403', |
||
| 142 | 'city' => 'Stellaberg', |
||
| 143 | 'street' => 'street', |
||
| 144 | 'countryId' => $this->getValidCountryId(), |
||
| 145 | 'id' => $addressId, |
||
| 146 | ], |
||
| 147 | ], |
||
| 148 | ], |
||
| 149 | ]; |
||
| 150 | |||
| 151 | return $order; |
||
| 152 | } |
||
| 154 |