Conditions | 12 |
Paths | 21 |
Total Lines | 31 |
Code Lines | 17 |
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 |
||
45 | public function execute(Order $order): void |
||
46 | { |
||
47 | if (!$order->orderNumber) { |
||
48 | return; |
||
49 | } |
||
50 | /** @var OrderInterface $orderSylius */ |
||
51 | $orderSylius = $this->orderRepository->findOneBy(['id' => $order->orderNumber]); |
||
52 | |||
53 | /** @var ShipmentInterface $firstShipment */ |
||
54 | $firstShipment = $orderSylius->getShipments()->first(); |
||
55 | |||
56 | /** @var ShipmentInterface $lastShipment */ |
||
57 | $lastShipment = $orderSylius->getShipments()->last(); |
||
58 | |||
59 | if ($order->isCompleted()) { |
||
60 | $this->applyStateMachineOrderTransition($orderSylius, OrderTransitions::TRANSITION_FULFILL); |
||
61 | $this->applyStateMachineShipmentsTransition($firstShipment, ShipmentTransitions::TRANSITION_SHIP); |
||
62 | } |
||
63 | if ($order->isCanceled() || $order->isExpired()) { |
||
64 | $this->applyStateMachineOrderTransition($orderSylius, OrderTransitions::TRANSITION_CANCEL); |
||
65 | } |
||
66 | |||
67 | if ($order->isShipping() && $this->isConfirmNotify($order, $firstShipment) && false === $this->isShippingAllItems($firstShipment)) { |
||
68 | return; |
||
69 | } |
||
70 | if ($order->isShipping() && false === $this->isShippingAllItems($firstShipment)) { |
||
71 | $this->createPartialShipFromMollie->create($orderSylius, $order); |
||
72 | $this->applyStateMachineShipmentsTransition($lastShipment, ShipmentTransitionsPartial::TRANSITION_CREATE_AND_SHIP); |
||
73 | } |
||
74 | if ($order->isShipping() && true === $this->isShippingAllItems($firstShipment)) { |
||
75 | $this->applyStateMachineShipmentsTransition($lastShipment, ShipmentTransitions::TRANSITION_SHIP); |
||
76 | } |
||
119 |