Conditions | 10 |
Paths | 9 |
Total Lines | 43 |
Code Lines | 22 |
Lines | 14 |
Ratio | 32.56 % |
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 |
||
24 | public function process(ItemHolderInterface $TargetOrder, PurchaseContext $context) |
||
25 | { |
||
26 | $dateTime = new \DateTime(); |
||
27 | $OriginOrder = $context->getOriginHolder(); |
||
28 | |||
29 | // 編集 |
||
30 | if ($TargetOrder->getId()) { |
||
31 | // 発送済 |
||
32 | if ($TargetOrder->getOrderStatus()->getId() == $this->app['config']['order_deliv']) { |
||
33 | // 編集前と異なる場合のみ更新 |
||
34 | View Code Duplication | if ($TargetOrder->getOrderStatus()->getId() != $OriginOrder->getOrderStatus()->getId()) { |
|
35 | $TargetOrder->setCommitDate($dateTime); |
||
36 | // お届け先情報の発送日も更新する. |
||
37 | $Shippings = $TargetOrder->getShippings(); |
||
38 | foreach ($Shippings as $Shipping) { |
||
39 | $Shipping->setShippingCommitDate($dateTime); |
||
40 | } |
||
41 | } |
||
42 | // 入金済 |
||
43 | View Code Duplication | } elseif ($TargetOrder->getOrderStatus()->getId() == $this->app['config']['order_pre_end']) { |
|
44 | // 編集前と異なる場合のみ更新 |
||
45 | if ($TargetOrder->getOrderStatus()->getId() != $OriginOrder->getOrderStatus()->getId()) { |
||
46 | $TargetOrder->setPaymentDate($dateTime); |
||
47 | } |
||
48 | } |
||
49 | // 新規 |
||
50 | } else { |
||
51 | // 発送済 |
||
52 | if ($TargetOrder->getOrderStatus()->getId() == $this->app['config']['order_deliv']) { |
||
53 | $TargetOrder->setCommitDate($dateTime); |
||
54 | // お届け先情報の発送日も更新する. |
||
55 | $Shippings = $TargetOrder->getShippings(); |
||
56 | foreach ($Shippings as $Shipping) { |
||
57 | $Shipping->setShippingCommitDate($dateTime); |
||
58 | } |
||
59 | // 入金済 |
||
60 | } elseif ($TargetOrder->getOrderStatus()->getId() == $this->app['config']['order_pre_end']) { |
||
61 | $TargetOrder->setPaymentDate($dateTime); |
||
62 | } |
||
63 | // 受注日時 |
||
64 | $TargetOrder->setOrderDate($dateTime); |
||
65 | } |
||
66 | } |
||
67 | } |
||
68 |