| Conditions | 14 |
| Paths | 96 |
| Total Lines | 72 |
| Code Lines | 47 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 25 | public function __construct(RequestInterface $request, $data) |
||
| 26 | { |
||
| 27 | parent::__construct($request, $data); |
||
| 28 | |||
| 29 | $security = new Security(); |
||
| 30 | |||
| 31 | try { |
||
| 32 | $this->redsysMessages = (new Factory(new CatalogLoader()))->createCatalogByLanguage(array_key_exists('language', $this->request->getParameters()) ? $this->request->getParameters()['language'] : 'en'); |
||
| 33 | } catch (CatalogNotFoundException $e) { |
||
| 34 | $this->redsysMessages = (new Factory(new CatalogLoader()))->createCatalogByLanguage('en'); |
||
| 35 | } |
||
| 36 | |||
| 37 | if (!isset($data['CODIGO'])) { |
||
| 38 | throw new InvalidResponseException('Invalid response from payment gateway (no data)'); |
||
| 39 | } |
||
| 40 | |||
| 41 | if (!isset($data['OPERACION'])) { |
||
| 42 | if ('0' == $data['CODIGO']) { |
||
| 43 | throw new InvalidResponseException('Invalid response from payment gateway (no data)'); |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | // Exceeder API rate limit |
||
| 48 | if ('SIS0295' == $data['CODIGO'] || '9295' == $data['CODIGO']) { |
||
| 49 | throw new RequestException('Too many requests. "'.$data['CODIGO'].'"', MessageFactoryDiscovery::find()->createRequest('POST', $this->getRequest()->getEndpoint(), ['SOAPAction' => 'trataPeticion'])); |
||
| 50 | } |
||
| 51 | |||
| 52 | if (isset($data['OPERACION']['DS_ORDER'])) { |
||
| 53 | $this->usingUpcaseResponse = true; |
||
| 54 | } |
||
| 55 | |||
| 56 | if (!empty($data['OPERACION'])) { |
||
| 57 | if (!empty($data['OPERACION']['Ds_CardNumber'])) { |
||
| 58 | $signature_keys = [ |
||
| 59 | 'Ds_Amount', |
||
| 60 | 'Ds_Order', |
||
| 61 | 'Ds_MerchantCode', |
||
| 62 | 'Ds_Currency', |
||
| 63 | 'Ds_Response', |
||
| 64 | 'Ds_CardNumber', |
||
| 65 | 'Ds_TransactionType', |
||
| 66 | 'Ds_SecurePayment', |
||
| 67 | ]; |
||
| 68 | } else { |
||
| 69 | $signature_keys = [ |
||
| 70 | 'Ds_Amount', |
||
| 71 | 'Ds_Order', |
||
| 72 | 'Ds_MerchantCode', |
||
| 73 | 'Ds_Currency', |
||
| 74 | 'Ds_Response', |
||
| 75 | 'Ds_TransactionType', |
||
| 76 | 'Ds_SecurePayment', |
||
| 77 | ]; |
||
| 78 | } |
||
| 79 | |||
| 80 | $signature_data = ''; |
||
| 81 | foreach ($signature_keys as $key) { |
||
| 82 | $value = $this->getKey($key); |
||
| 83 | if (null === $value) { |
||
| 84 | throw new InvalidResponseException('Invalid response from payment gateway (missing data)'); |
||
| 85 | } |
||
| 86 | $signature_data .= $value; |
||
| 87 | } |
||
| 88 | |||
| 89 | $this->returnSignature = $security->createSignature( |
||
| 90 | $signature_data, |
||
| 91 | $this->getKey('Ds_Order'), |
||
| 92 | $this->request->getHmacKey() |
||
| 93 | ); |
||
| 94 | |||
| 95 | if ($this->returnSignature != $this->getKey('Ds_Signature')) { |
||
| 96 | throw new InvalidResponseException('Invalid response from payment gateway (signature mismatch)'); |
||
| 97 | } |
||
| 194 |
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