Conditions | 5 |
Paths | 4 |
Total Lines | 70 |
Code Lines | 44 |
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 |
||
65 | public function build(array $buildSubject) |
||
66 | { |
||
67 | if (!isset($buildSubject['payment']) |
||
68 | || !$buildSubject['payment'] instanceof PaymentDataObjectInterface |
||
69 | ) { |
||
70 | throw new \InvalidArgumentException('Payment data object should be provided'); |
||
71 | } |
||
72 | |||
73 | $result = []; |
||
74 | |||
75 | $paymentDO = $buildSubject['payment']; |
||
76 | |||
77 | $payment = $paymentDO->getPayment(); |
||
78 | |||
79 | $order = $payment->getOrder(); |
||
80 | |||
81 | $creditmemo = $payment->getCreditMemo(); |
||
82 | |||
83 | $total = $creditmemo->getGrandTotal(); |
||
84 | |||
85 | $result = [ |
||
86 | self::MOIP_ORDER_ID => $order->getExtOrderId(), |
||
87 | 'send' => [ |
||
88 | 'amount' => $this->configPayment->formatPrice($total), |
||
89 | ], |
||
90 | ]; |
||
91 | |||
92 | if ($order->getPayment()->getMethodInstance()->getCode() === ConfigProviderBoleto::CODE) { |
||
93 | $bankNumber = $creditmemo->getData(self::BANK_NUMBER); |
||
94 | $agencyNumber = $creditmemo->getData(self::AGENCY_NUMBER); |
||
95 | $agencyCheckNumber = $creditmemo->getData(self::AGENCY_CHECK_NUMBER); |
||
96 | $accountNumber = $creditmemo->getData(self::ACCOUNT_NUMBER); |
||
97 | $accountCheckNumber = $creditmemo->getData(self::ACCOUNT_CHECK_NUMBER); |
||
98 | $holderFullname = $creditmemo->getData(self::HOLDER_FULLNAME); |
||
99 | $holderDocumment = $creditmemo->getData(self::HOLDER_DOCUMENT_NUMBER); |
||
100 | |||
101 | $typeDocument = 'CPF'; |
||
102 | $taxDocument = preg_replace('/[^0-9]/', '', $holderDocumment); |
||
103 | if (strlen($taxDocument) === 14) { |
||
104 | $typeDocument = 'CNPJ'; |
||
105 | } |
||
106 | |||
107 | $resultBoleto = [ |
||
108 | 'send' => [ |
||
109 | 'amount' => $this->configPayment->formatPrice($total), |
||
110 | 'refundingInstrument' => [ |
||
111 | 'method' => 'BANK_ACCOUNT', |
||
112 | 'bankAccount' => [ |
||
113 | 'type' => 'CHECKING', |
||
114 | 'bankNumber' => $bankNumber, |
||
115 | 'agencyNumber' => $agencyNumber, |
||
116 | 'agencyCheckNumber' => $agencyCheckNumber, |
||
117 | 'accountNumber' => $accountNumber, |
||
118 | 'accountCheckNumber' => $accountCheckNumber, |
||
119 | 'holder' => [ |
||
120 | 'fullname' => $holderFullname, |
||
121 | 'taxDocument' => [ |
||
122 | 'type' => $typeDocument, |
||
123 | 'number' => $taxDocument, |
||
124 | ], |
||
125 | ], |
||
126 | ], |
||
127 | ], |
||
128 | ], |
||
129 | ]; |
||
130 | |||
131 | $result = array_merge($result, $resultBoleto); |
||
132 | } |
||
133 | |||
134 | return $result; |
||
135 | } |
||
137 |
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