| Conditions | 10 |
| Paths | 11 |
| Total Lines | 48 |
| Code Lines | 30 |
| 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 |
||
| 15 | public function execute($request): void |
||
| 16 | { |
||
| 17 | RequestNotSupportedException::assertSupports($this, $request); |
||
| 18 | |||
| 19 | $details = ArrayObject::ensureArrayObject($request->getModel()); |
||
| 20 | |||
| 21 | $status = $details['status']; |
||
| 22 | |||
| 23 | if (null != $status) { |
||
| 24 | switch ($status) { |
||
| 25 | case BraintreeApiClientInterface::FAILED: |
||
| 26 | $request->markFailed(); |
||
| 27 | |||
| 28 | return; |
||
| 29 | case BraintreeApiClientInterface::AUTHORIZED: |
||
| 30 | if ($this->hasSuccessfulTransaction($details)) { |
||
| 31 | $request->markAuthorized(); |
||
| 32 | } else { |
||
| 33 | $request->markUnknown(); |
||
| 34 | } |
||
| 35 | |||
| 36 | return; |
||
| 37 | case BraintreeApiClientInterface::CAPTURED: |
||
| 38 | if ($this->hasSuccessfulTransaction($details)) { |
||
| 39 | $request->markCaptured(); |
||
| 40 | } else { |
||
| 41 | $request->markUnknown(); |
||
| 42 | } |
||
| 43 | |||
| 44 | return; |
||
| 45 | case BraintreeApiClientInterface::REFUNDED: |
||
| 46 | if ($this->hasSuccessfulTransaction($details)) { |
||
| 47 | $request->markRefunded(); |
||
| 48 | } else { |
||
| 49 | $request->markUnknown(); |
||
| 50 | } |
||
| 51 | |||
| 52 | return; |
||
| 53 | } |
||
| 54 | } |
||
| 55 | |||
| 56 | if ($details['paymentMethodNonce']) { |
||
| 57 | $request->markPending(); |
||
| 58 | |||
| 59 | return; |
||
| 60 | } |
||
| 61 | |||
| 62 | $request->markNew(); |
||
| 63 | } |
||
| 78 |