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