| Conditions | 8 | 
| Paths | 11 | 
| Total Lines | 53 | 
| 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  | 
            ||
| 22 | public function execute(AmazonpayCallTransfer $amazonpayCallTransfer)  | 
            ||
| 23 |     { | 
            ||
| 24 | if (!in_array($amazonpayCallTransfer->getAmazonpayPayment()->getStatus(), [  | 
            ||
| 25 | AmazonpayConstants::OMS_STATUS_CAPTURE_PENDING,  | 
            ||
| 26 | AmazonpayConstants::OMS_STATUS_AUTH_OPEN,  | 
            ||
| 27 | AmazonpayConstants::OMS_STATUS_PAYMENT_METHOD_CHANGED,  | 
            ||
| 28 |         ], true)) { | 
            ||
| 29 | return $amazonpayCallTransfer;  | 
            ||
| 30 | }  | 
            ||
| 31 | |||
| 32 | if ($amazonpayCallTransfer->getAmazonpayPayment()->getCaptureDetails()  | 
            ||
| 33 |             && $amazonpayCallTransfer->getAmazonpayPayment()->getCaptureDetails()->getAmazonCaptureId()) { | 
            ||
| 34 | return $amazonpayCallTransfer;  | 
            ||
| 35 | }  | 
            ||
| 36 | |||
| 37 | $amazonpayCallTransfer->getAmazonpayPayment()->getCaptureDetails()->setCaptureReferenceId(  | 
            ||
| 38 | $this->generateOperationReferenceId($amazonpayCallTransfer)  | 
            ||
| 39 | );  | 
            ||
| 40 | |||
| 41 | $amazonpayCallTransfer = parent::execute($amazonpayCallTransfer);  | 
            ||
| 42 | |||
| 43 |         if (!$amazonpayCallTransfer->getAmazonpayPayment()->getResponseHeader()->getIsSuccess()) { | 
            ||
| 44 | return $amazonpayCallTransfer;  | 
            ||
| 45 | }  | 
            ||
| 46 | |||
| 47 | $isPartialProcessing = $this->isPartialProcessing($this->paymentEntity, $amazonpayCallTransfer);  | 
            ||
| 48 | |||
| 49 |         if ($isPartialProcessing) { | 
            ||
| 50 | $this->paymentEntity = $this->duplicatePaymentEntity($this->paymentEntity);  | 
            ||
| 51 | }  | 
            ||
| 52 | |||
| 53 | $amazonpayCallTransfer->getAmazonpayPayment()->setCaptureDetails(  | 
            ||
| 54 | $this->apiResponse->getCaptureDetails()  | 
            ||
| 55 | );  | 
            ||
| 56 | $this->paymentEntity->setAmazonCaptureId(  | 
            ||
| 57 | $this->apiResponse->getCaptureDetails()->getAmazonCaptureId()  | 
            ||
| 58 | );  | 
            ||
| 59 | $this->paymentEntity->setCaptureReferenceId(  | 
            ||
| 60 | $this->apiResponse->getCaptureDetails()->getCaptureReferenceId()  | 
            ||
| 61 | );  | 
            ||
| 62 | $newStatus = $this->getPaymentStatus($amazonpayCallTransfer->getAmazonpayPayment()->getCaptureDetails()->getCaptureStatus());  | 
            ||
| 63 | |||
| 64 |         if ($newStatus !== '') { | 
            ||
| 65 | $this->paymentEntity->setStatus($newStatus);  | 
            ||
| 66 | }  | 
            ||
| 67 | |||
| 68 | $this->paymentEntity->save();  | 
            ||
| 69 | |||
| 70 |         if ($isPartialProcessing) { | 
            ||
| 71 | $this->assignAmazonpayPaymentToItemsIfNew($this->paymentEntity, $amazonpayCallTransfer);  | 
            ||
| 72 | }  | 
            ||
| 73 | |||
| 74 | return $amazonpayCallTransfer;  | 
            ||
| 75 | }  | 
            ||
| 100 |