1 | <?php |
||
2 | |||
3 | namespace Omnipay\Redsys\Message; |
||
4 | |||
5 | use AvaiBookSports\Component\RedsysMessages\Exception\CatalogNotFoundException; |
||
6 | use AvaiBookSports\Component\RedsysMessages\Factory; |
||
7 | use AvaiBookSports\Component\RedsysMessages\Loader\CatalogLoader; |
||
8 | use Omnipay\Common\Exception\RuntimeException; |
||
9 | use Omnipay\Common\Message\AbstractRequest as MessageAbstractRequest; |
||
10 | |||
11 | abstract class AbstractRequest extends MessageAbstractRequest |
||
12 | { |
||
13 | /** @var array */ |
||
14 | protected static $consumerLanguages = [ |
||
15 | 'es' => '001', // Spanish |
||
16 | 'en' => '002', // English |
||
17 | 'ca' => '003', // Catalan - same as Valencian (010) |
||
18 | 'fr' => '004', // French |
||
19 | 'de' => '005', // German |
||
20 | 'nl' => '006', // Dutch |
||
21 | 'it' => '007', // Italian |
||
22 | 'sv' => '008', // Swedish |
||
23 | 'pt' => '009', // Portuguese |
||
24 | 'pl' => '011', // Polish |
||
25 | 'gl' => '012', // Galician |
||
26 | 'eu' => '013', // Basque |
||
27 | 'bg' => '100', // Undocumented |
||
28 | 'zh' => '156', // Undocumented |
||
29 | 'hr' => '191', // Undocumented |
||
30 | 'cs' => '203', // Undocumented |
||
31 | 'da' => '208', // Undocumented |
||
32 | 'et' => '233', // Undocumented |
||
33 | 'fi' => '246', // Undocumented |
||
34 | 'el' => '300', // Undocumented |
||
35 | 'hu' => '348', // Undocumented |
||
36 | 'ja' => '392', // Undocumented |
||
37 | 'lv' => '428', // Undocumented |
||
38 | 'lt' => '440', // Undocumented |
||
39 | 'mt' => '470', // Undocumented |
||
40 | 'ro' => '642', // Undocumented |
||
41 | 'ru' => '643', // Undocumented |
||
42 | 'sk' => '703', // Undocumented |
||
43 | 'sl' => '705', // Undocumented |
||
44 | 'tr' => '792', // Undocumented |
||
45 | ]; |
||
46 | |||
47 | abstract public function getEndpoint(); |
||
48 | |||
49 | 2 | public function getCardholder() |
|
50 | { |
||
51 | 2 | return $this->getParameter('cardholder'); |
|
52 | } |
||
53 | |||
54 | 4 | public function setCardholder($value) |
|
55 | { |
||
56 | 4 | return $this->setParameter('cardholder', $value); |
|
57 | } |
||
58 | |||
59 | /** |
||
60 | * Get the language presented to the consumer. |
||
61 | * |
||
62 | * @return string|null ISO 639-1 code |
||
63 | */ |
||
64 | 10 | public function getLanguage() |
|
65 | { |
||
66 | 10 | return $this->getParameter('language'); |
|
67 | } |
||
68 | |||
69 | /** |
||
70 | * Set the language presented to the consumer. |
||
71 | * |
||
72 | * @param string ISO 639-1 code |
||
0 ignored issues
–
show
|
|||
73 | */ |
||
74 | 9 | public function setLanguage($value) |
|
75 | { |
||
76 | 9 | return $this->setParameter('language', $value); |
|
77 | } |
||
78 | |||
79 | /** |
||
80 | * Returns Redsys language code or English by default. |
||
81 | * |
||
82 | * @return string |
||
83 | */ |
||
84 | 9 | public function getConsumerLanguage() |
|
85 | { |
||
86 | 9 | $language = $this->getLanguage() ?: 'en'; |
|
87 | |||
88 | 9 | if (!array_key_exists($language, self::$consumerLanguages)) { |
|
89 | 2 | $language = 'en'; |
|
90 | // throw new OmnipayException(sprintf('Language "%s" is not supported by the gateway', $language)); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
67% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
91 | 2 | } |
|
92 | |||
93 | 9 | return self::$consumerLanguages[$language]; |
|
94 | } |
||
95 | |||
96 | 21 | public function getHmacKey() |
|
97 | { |
||
98 | 21 | return $this->getParameter('hmacKey'); |
|
99 | } |
||
100 | |||
101 | 32 | public function setHmacKey($value) |
|
102 | { |
||
103 | 32 | return $this->setParameter('hmacKey', $value); |
|
104 | } |
||
105 | |||
106 | 7 | public function getMerchantData() |
|
107 | { |
||
108 | 7 | return $this->getParameter('merchantData'); |
|
109 | } |
||
110 | |||
111 | 7 | public function setMerchantData($value) |
|
112 | { |
||
113 | 7 | return $this->setParameter('merchantData', $value); |
|
114 | } |
||
115 | |||
116 | 16 | public function getMerchantId() |
|
117 | { |
||
118 | 16 | return $this->getParameter('merchantId'); |
|
119 | } |
||
120 | |||
121 | 32 | public function setMerchantId($value) |
|
122 | { |
||
123 | 32 | return $this->setParameter('merchantId', $value); |
|
124 | } |
||
125 | |||
126 | 13 | public function getMerchantName() |
|
127 | { |
||
128 | 13 | return $this->getParameter('merchantName'); |
|
129 | } |
||
130 | |||
131 | 29 | public function setMerchantName($value) |
|
132 | { |
||
133 | 29 | return $this->setParameter('merchantName', $value); |
|
134 | } |
||
135 | |||
136 | 16 | public function getTerminalId() |
|
137 | { |
||
138 | 16 | return $this->getParameter('terminalId'); |
|
139 | } |
||
140 | |||
141 | 32 | public function setTerminalId($value) |
|
142 | { |
||
143 | 32 | return $this->setParameter('terminalId', $value); |
|
144 | } |
||
145 | |||
146 | /** |
||
147 | * Override the abstract method to add requirement that it must start with 4 numeric characters. |
||
148 | * |
||
149 | * @param string|int $value The transaction ID (merchant order) to set for the transaction |
||
150 | */ |
||
151 | 22 | public function setTransactionId($value) |
|
152 | { |
||
153 | 22 | if (strlen($value) > 12) { |
|
154 | 1 | throw new RuntimeException('"transactionId" has a maximum length of 12 characters'); |
|
155 | } |
||
156 | |||
157 | 21 | parent::setTransactionId($value); |
|
158 | 21 | } |
|
159 | |||
160 | 1 | public function getMessageCatalog() |
|
161 | { |
||
162 | try { |
||
163 | 1 | return (new Factory(new CatalogLoader()))->createCatalogByLanguage($this->getLanguage() ?: 'en'); |
|
164 | 1 | } catch (CatalogNotFoundException $e) { |
|
165 | 1 | return (new Factory(new CatalogLoader()))->createCatalogByLanguage('en'); |
|
166 | } |
||
167 | } |
||
168 | } |
||
169 |
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