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