Conditions | 13 |
Paths | 20 |
Total Lines | 49 |
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 |
||
52 | public function execute($request): void |
||
53 | { |
||
54 | RequestNotSupportedException::assertSupports($this, $request); |
||
55 | |||
56 | $details = ArrayObject::ensureArrayObject($request->getModel()); |
||
57 | |||
58 | $this->gateway->execute($httpRequest = new GetHttpRequest()); |
||
59 | |||
60 | if (!isset($httpRequest->request['merchantReference']) || empty($httpRequest->request['merchantReference'])) { |
||
61 | $details['response_status'] = 401; |
||
62 | return; |
||
63 | } |
||
64 | |||
65 | if (!isset($details['merchantReference']) || ($details['merchantReference'] !== $httpRequest->request['merchantReference'])) { |
||
66 | $details['response_status'] = 402; |
||
67 | return; |
||
68 | } |
||
69 | |||
70 | if (false === $this->api->verifyNotification($httpRequest->request)) { |
||
71 | $details['response_status'] = 403; |
||
72 | return; |
||
73 | } |
||
74 | |||
75 | if (isset($httpRequest->request['eventCode'])) { |
||
76 | $httpRequest->request['authResult'] = $httpRequest->request['eventCode']; |
||
77 | |||
78 | if (AdyenBridgeInterface::AUTHORISATION === $httpRequest->request['eventCode']) { |
||
79 | if (true === filter_var($httpRequest->request['success'], FILTER_VALIDATE_BOOLEAN)) { |
||
80 | $httpRequest->request['authResult'] = AdyenBridgeInterface::AUTHORISED; |
||
81 | } elseif (!empty($httpRequest->request['reason'])) { |
||
82 | $httpRequest->request['authResult'] = AdyenBridgeInterface::REFUSED; |
||
83 | } |
||
84 | } |
||
85 | |||
86 | if (AdyenBridgeInterface::REFUND === $httpRequest->request['eventCode']) { |
||
87 | if (true === filter_var($httpRequest->request['success'], FILTER_VALIDATE_BOOLEAN)) { |
||
88 | $httpRequest->request['authResult'] = AdyenBridgeInterface::REFUND; |
||
89 | } elseif (!empty($httpRequest->request['reason'])) { |
||
90 | $httpRequest->request['authResult'] = AdyenBridgeInterface::REFUSED; |
||
91 | } |
||
92 | } |
||
93 | } |
||
94 | |||
95 | $details['authResult'] = $httpRequest->request['authResult']; |
||
96 | |||
97 | $details['pspReference'] = $httpRequest->request['pspReference']; |
||
98 | |||
99 | $details['response_status'] = 200; |
||
100 | } |
||
101 | |||
113 |