| Conditions | 8 |
| Paths | 19 |
| Total Lines | 69 |
| Code Lines | 45 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 75 | public function handle(array $handlingSubject, array $response) |
||
| 76 | { |
||
| 77 | if (!isset($handlingSubject['payment']) |
||
| 78 | || !$handlingSubject['payment'] instanceof PaymentDataObjectInterface |
||
| 79 | ) { |
||
| 80 | throw new \InvalidArgumentException('Payment data object should be provided'); |
||
| 81 | } |
||
| 82 | |||
| 83 | $paymentDO = $handlingSubject['payment']; |
||
| 84 | |||
| 85 | $payment = $paymentDO->getPayment(); |
||
| 86 | |||
| 87 | if ($payment->getMethod() === 'moip_magento2_cc') { |
||
| 88 | $paymentAddtional = $response['fundingInstrument']; |
||
| 89 | |||
| 90 | if (isset($paymentAddtional['creditCard'])) { |
||
| 91 | $ccType = $this->mapperCcType($paymentAddtional['creditCard']['brand']); |
||
| 92 | $ccLast4 = $paymentAddtional['creditCard']['last4']; |
||
| 93 | $ccHolderName = $paymentAddtional['creditCard']['holder']['fullname']; |
||
| 94 | } |
||
| 95 | $payment->setCcType($ccType); |
||
| 96 | $payment->setCcLast4($ccLast4); |
||
| 97 | $payment->setCcOwner($ccHolderName); |
||
| 98 | } |
||
| 99 | |||
| 100 | if ($payment->getMethod() === 'moip_magento2_cc_vault') { |
||
| 101 | $paymentAddtional = $response['fundingInstrument']; |
||
| 102 | |||
| 103 | if (isset($paymentAddtional['creditCard'])) { |
||
| 104 | $ccType = $this->mapperCcType($paymentAddtional['creditCard']['brand']); |
||
| 105 | $ccLast4 = $paymentAddtional['creditCard']['last4']; |
||
| 106 | $ccHolderName = $paymentAddtional['creditCard']['holder']['fullname']; |
||
| 107 | } |
||
| 108 | $payment->setCcType($ccType); |
||
| 109 | $payment->setCcLast4($ccLast4); |
||
| 110 | $payment->setCcOwner($ccHolderName); |
||
| 111 | |||
| 112 | $payment->setAdditionalInformation( |
||
| 113 | self::PAYER_CC_TYPE, |
||
| 114 | $ccType |
||
| 115 | ); |
||
| 116 | $payment->setAdditionalInformation( |
||
| 117 | self::PAYER_CC_NUMBER, |
||
| 118 | 'xxxx xxxx xxxx '.$ccLast4 |
||
| 119 | ); |
||
| 120 | $payment->setAdditionalInformation( |
||
| 121 | self::PAYER_HOLDER_FULLNAME, |
||
| 122 | $ccHolderName |
||
| 123 | ); |
||
| 124 | $payment->setAdditionalInformation( |
||
| 125 | self::PAYER_CC_INSTALLMENTS, |
||
| 126 | $response['installmentCount'] |
||
| 127 | ); |
||
| 128 | } |
||
| 129 | |||
| 130 | if ($payment->getMethod() === 'moip_magento2_boleto') { |
||
| 131 | $payment->setAdditionalInformation( |
||
| 132 | self::BOLETO_LINE_CODE, |
||
| 133 | $response['fundingInstrument']['boleto']['lineCode'] |
||
| 134 | ); |
||
| 135 | $payment->setAdditionalInformation( |
||
| 136 | self::BOLETO_PRINT_HREF, |
||
| 137 | $response['_links']['payBoleto']['printHref'] |
||
| 138 | ); |
||
| 139 | } |
||
| 140 | |||
| 141 | $payment->setTransactionId($response[self::TXN_ID]); |
||
| 142 | $payment->setIsTransactionPending(1); |
||
| 143 | $payment->setIsTransactionClosed(false); |
||
| 144 | } |
||
| 170 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths