| Conditions | 10 | 
| Paths | 144 | 
| Total Lines | 82 | 
| Code Lines | 47 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 2 | ||
| 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  | 
            ||
| 134 | public function getData()  | 
            ||
| 135 |     { | 
            ||
| 136 |         $this->validate('merchantId', 'amount', 'currency'); | 
            ||
| 137 | |||
| 138 | $formattedItems = [];  | 
            ||
| 139 | $items = $this->getItems();  | 
            ||
| 140 |         if ($items) { | 
            ||
| 141 |             foreach ($items as $item) { | 
            ||
| 142 | $itemPrice = $this->getItemPriceInteger($item);  | 
            ||
| 143 | $formattedItems[] = [  | 
            ||
| 144 | 'amountOfMoney' => [  | 
            ||
| 145 | 'amount' => $item->getQuantity() * $itemPrice,  | 
            ||
| 146 | 'currencyCode' => $this->getCurrency(),  | 
            ||
| 147 | ],  | 
            ||
| 148 | 'orderLineDetails' => [  | 
            ||
| 149 | 'productName' => $item->getName(),  | 
            ||
| 150 | 'productPrice' => $itemPrice,  | 
            ||
| 151 | 'quantity' => (int) $item->getQuantity(),  | 
            ||
| 152 | ],  | 
            ||
| 153 | ];  | 
            ||
| 154 | }  | 
            ||
| 155 | }  | 
            ||
| 156 | |||
| 157 | $data = [  | 
            ||
| 158 | 'cardPaymentMethodSpecificInput' => [  | 
            ||
| 159 | 'authorizationMode' => 'SALE',  | 
            ||
| 160 | 'transactionChannel' => $this->getTransactionChannel() ?? 'ECOMMERCE',  | 
            ||
| 161 | ],  | 
            ||
| 162 | 'hostedCheckoutSpecificInput' => [  | 
            ||
| 163 | // if adding locale, validate locale against known formats  | 
            ||
| 164 | // @see https://docs.direct.worldline-solutions.com/en/integration/basic-integration-methods/hosted-checkout-page#chooselanguageversion  | 
            ||
| 165 | // 'locale' => 'en_UK',  | 
            ||
| 166 | 'returnUrl' => $this->getReturnUrl(),  | 
            ||
| 167 | ],  | 
            ||
| 168 | 'order' => [  | 
            ||
| 169 | 'amountOfMoney' => [  | 
            ||
| 170 | 'amount' => $this->getAmountInteger(),  | 
            ||
| 171 | 'currencyCode' => $this->getCurrency(),  | 
            ||
| 172 | ],  | 
            ||
| 173 | 'references' => [  | 
            ||
| 174 | 'descriptor' => $this->getMerchantName(),  | 
            ||
| 175 | 'merchantReference' => $this->getTransactionId(),  | 
            ||
| 176 | ],  | 
            ||
| 177 | 'shoppingCart' => [  | 
            ||
| 178 | 'items' => $formattedItems,  | 
            ||
| 179 | ],  | 
            ||
| 180 | ],  | 
            ||
| 181 | ];  | 
            ||
| 182 | |||
| 183 |         if ($this->getAvailablePaymentProducts() !== null) { | 
            ||
| 184 |             if (!isset($data['hostedCheckoutSpecificInput']['paymentProductFilters'])) { | 
            ||
| 185 | $data['hostedCheckoutSpecificInput']['paymentProductFilters'] = [];  | 
            ||
| 186 | }  | 
            ||
| 187 | $data['hostedCheckoutSpecificInput']['paymentProductFilters']['restrictTo'] = [  | 
            ||
| 188 | 'products' => $this->getAvailablePaymentProducts(),  | 
            ||
| 189 | ];  | 
            ||
| 190 | }  | 
            ||
| 191 | |||
| 192 |         if ($this->getExcludedPaymentProducts() !== null) { | 
            ||
| 193 |             if (!isset($data['hostedCheckoutSpecificInput']['paymentProductFilters'])) { | 
            ||
| 194 | $data['hostedCheckoutSpecificInput']['paymentProductFilters'] = [];  | 
            ||
| 195 | }  | 
            ||
| 196 | $data['hostedCheckoutSpecificInput']['paymentProductFilters']['exclude'] = [  | 
            ||
| 197 | 'products' => $this->getExcludedPaymentProducts(),  | 
            ||
| 198 | ];  | 
            ||
| 199 | }  | 
            ||
| 200 | |||
| 201 |         if ($this->getShowResultPage() !== null) { | 
            ||
| 202 | $data['hostedCheckoutSpecificInput']['showResultPage'] = (bool) $this->getShowResultPage();  | 
            ||
| 203 | }  | 
            ||
| 204 | |||
| 205 |         if ($this->getSessionTimeout() !== null) { | 
            ||
| 206 | $data['hostedCheckoutSpecificInput']['sessionTimeout'] = (int) $this->getSessionTimeout();  | 
            ||
| 207 | }  | 
            ||
| 208 | |||
| 209 |         if ($this->getNotifyUrl() !== null) { | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 210 | $data['feedbacks'] = [  | 
            ||
| 211 | 'webhookUrl' => $this->getNotifyUrl(),  | 
            ||
| 212 | ];  | 
            ||
| 213 | }  | 
            ||
| 214 | |||
| 215 | return $data;  | 
            ||
| 216 | }  | 
            ||
| 298 |