Conditions | 19 |
Paths | 19 |
Total Lines | 44 |
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 |
||
100 | private function resolvePaymentStatus(string $authResult, GetStatusInterface $request): void |
||
101 | { |
||
102 | switch ($authResult) { |
||
103 | case null: |
||
104 | $request->markNew(); |
||
105 | break; |
||
106 | case AdyenBridgeInterface::AUTHORISED: |
||
107 | case AdyenBridgeInterface::AUTHORISATION: |
||
108 | $request->markCaptured(); |
||
109 | break; |
||
110 | case AdyenBridgeInterface::PENDING: |
||
111 | $request->markPending(); |
||
112 | break; |
||
113 | case AdyenBridgeInterface::CAPTURE: |
||
114 | $request->markCaptured(); |
||
115 | break; |
||
116 | case AdyenBridgeInterface::CANCELLED: |
||
117 | case AdyenBridgeInterface::CANCELLATION: |
||
118 | case AdyenBridgeInterface::CANCEL_OR_REFUND: |
||
119 | $request->markCanceled(); |
||
120 | break; |
||
121 | case AdyenBridgeInterface::REFUSED: |
||
122 | case AdyenBridgeInterface::ERROR: |
||
123 | $request->markFailed(); |
||
124 | break; |
||
125 | case AdyenBridgeInterface::NOTIFICATION_OF_CHARGEBACK: |
||
126 | case AdyenBridgeInterface::CHARGEBACK: |
||
127 | case AdyenBridgeInterface::CHARGEBACK_REVERSED: |
||
128 | case AdyenBridgeInterface::REFUND_FAILED: |
||
129 | case AdyenBridgeInterface::CAPTURE_FAILED: |
||
130 | $request->markSuspended(); |
||
131 | break; |
||
132 | case AdyenBridgeInterface::EXPIRE: |
||
133 | $request->markExpired(); |
||
134 | break; |
||
135 | case AdyenBridgeInterface::REFUND: |
||
136 | case AdyenBridgeInterface::REFUNDED_REVERSED: |
||
137 | $request->markRefunded(); |
||
138 | break; |
||
139 | default: |
||
140 | $request->markUnknown(); |
||
141 | break; |
||
142 | } |
||
143 | } |
||
144 | } |
||
145 |