Conditions | 10 |
Paths | 12 |
Total Lines | 38 |
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 |
||
50 | public function onPostExecute(Context $context) |
||
51 | { |
||
52 | $previousStack = $context->getPrevious(); |
||
53 | $previousStackSize = count($previousStack); |
||
54 | |||
55 | if ($previousStackSize > 1) { |
||
56 | return; |
||
57 | } |
||
58 | |||
59 | if (1 === $previousStackSize) { |
||
60 | $previousActionClassName = get_class($previousStack[0]->getAction()); |
||
61 | if (false === stripos($previousActionClassName, 'NotifyNullAction')) { |
||
62 | return; |
||
63 | } |
||
64 | } |
||
65 | |||
66 | /** @var Generic $request */ |
||
67 | $request = $context->getRequest(); |
||
68 | if (false === $request instanceof Generic) { |
||
69 | return; |
||
70 | } |
||
71 | |||
72 | if (false === $request instanceof GetStatusInterface && false === $request instanceof Notify) { |
||
73 | return; |
||
74 | } |
||
75 | |||
76 | /** @var PaymentInterface $payment */ |
||
77 | $payment = $request->getFirstModel(); |
||
78 | if (false === $payment instanceof PaymentInterface) { |
||
79 | return; |
||
80 | } |
||
81 | |||
82 | $context->getGateway()->execute($status = new GetStatus($payment)); |
||
83 | $value = $status->getValue(); |
||
84 | if ($payment->getState() !== $value && PaymentInterface::STATE_UNKNOWN !== $value) { |
||
85 | $this->updatePaymentState($payment, $value); |
||
86 | } |
||
87 | } |
||
88 | |||
103 |