Skip to content

Commit b82c45a

Browse files
committed
fixed php 7.4 compatibility
1 parent 7c4e6cf commit b82c45a

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616
],
1717
"require": {
18-
"php": ">=7.2",
18+
"php": ">=7.4",
1919
"ext-soap" : "*",
2020
"ext-json": "*",
2121
"ext-bcmath": "*",

src/Adapter/AdapterAbstract.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function getTransaction(): TransactionInterface
112112
public function setParameters(array $parameters = []): AdapterInterface
113113
{
114114
foreach ($parameters as $key => $value) {
115-
if($key == 'customer_card_number'){
115+
if($key === 'customer_card_number'){
116116
continue;
117117
}
118118
$key = strtolower($key);
@@ -198,7 +198,7 @@ protected function checkRequiredParameters(array $parameters)
198198
*/
199199
protected function getWSDL(): string
200200
{
201-
if (config('larapay.mode') == 'production') {
201+
if (config('larapay.mode') === 'production') {
202202
return $this->WSDL;
203203
} else {
204204
return $this->testWSDL;
@@ -210,7 +210,7 @@ protected function getWSDL(): string
210210
*/
211211
protected function getEndPoint(): string
212212
{
213-
if (config('larapay.mode') == 'production') {
213+
if (config('larapay.mode') === 'production') {
214214
return $this->endPoint;
215215
} else {
216216
return $this->testEndPoint;

src/Adapter/Pasargad/RSA.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ public static function rsa_encrypt($message, $public_key, $modulus, $keylength)
1515
$padded = RSA::add_PKCS1_padding($message, true, $keylength / 8);
1616
$number = RSA::binary_to_number($padded);
1717
$encrypted = RSA::pow_mod($number, $public_key, $modulus);
18-
$result = RSA::number_to_binary($encrypted, $keylength / 8);
1918

20-
return $result;
19+
return RSA::number_to_binary($encrypted, $keylength / 8);
2120
}
2221

2322
public static function rsa_decrypt($message, $private_key, $modulus, $keylength)
@@ -108,18 +107,18 @@ public static function remove_PKCS1_padding($data, $blocksize)
108107
{
109108
assert(strlen($data) == $blocksize);
110109
$data = substr($data, 1);
111-
if ($data{0} === '\0') {
110+
if ($data[0] === '\0') {
112111
die("Block type 0 not implemented.");
113112
}
114-
assert(($data{0} === "\x01") || ($data{0} === "\x02"));
113+
assert(($data[0] === "\x01") || ($data[0] === "\x02"));
115114
$offset = strpos($data, "\0", 1);
116115

117116
return substr($data, $offset + 1);
118117
}
119118

120119
public static function remove_KYP_padding($data, $blocksize)
121120
{
122-
assert(strlen($data) == $blocksize);
121+
assert(strlen($data) === $blocksize);
123122
$offset = strpos($data, "\0");
124123

125124
return substr($data, 0, $offset);
@@ -131,7 +130,7 @@ public static function binary_to_number($data)
131130
$radix = "1";
132131
$result = "0";
133132
for ($i = strlen($data) - 1; $i >= 0; $i--) {
134-
$digit = ord($data{$i});
133+
$digit = ord($data[$i]);
135134
$part_res = bcmul($digit, $radix);
136135
$result = bcadd($result, $part_res);
137136
$radix = bcmul($radix, $base);

src/Adapter/Pasargad/RSAProcessor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ public function __construct ($xmlRsaKey = null, $keyType = null)
2929
$xmlObj = null;
3030
$keyType = is_null($keyType) ? null : strtolower($keyType);
3131

32-
if ($keyType === null || $keyType == RSAKeyType::XMLString) {
33-
$xmlObj = simplexml_load_string($xmlRsaKey);
34-
} elseif ($keyType == RSAKeyType::XMLFile) {
32+
if ($keyType === RSAKeyType::XMLFile) {
3533
$xmlObj = simplexml_load_string(file_get_contents($xmlRsaKey));
34+
} else {
35+
$xmlObj = simplexml_load_string($xmlRsaKey);
3636
}
3737

3838
$this->modulus = RSA::binary_to_number(base64_decode($xmlObj->Modulus));

0 commit comments

Comments
 (0)