Skip to content

Commit cd6b22e

Browse files
author
Islam
authored
Merge pull request #5 from khandurdyiev/remove-iso-object-from-entitites
remove iso object from entitites
2 parents 8e26610 + d49e3c2 commit cd6b22e

File tree

4 files changed

+7
-18
lines changed

4 files changed

+7
-18
lines changed

src/Entities/ClientInfo/Account.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Khandurdyiev\MonoClient\Entities\ClientInfo;
66

7-
use Alcohol\ISO4217 as AlcoholISO4217;
87
use Khandurdyiev\MonoClient\ISO4217;
98
use Khandurdyiev\MonoClient\Utils\Utils;
109

@@ -21,7 +20,6 @@ class Account implements \JsonSerializable
2120
* @var array<int, string>
2221
*/
2322
private array $maskedPan;
24-
private ISO4217 $iso4217;
2523

2624
/**
2725
* @param array<string, mixed> $account
@@ -36,7 +34,6 @@ public function __construct(array $account)
3634
$this->type = (string)$account['type'];
3735
$this->iban = (string)$account['iban'];
3836
$this->maskedPan = (array)$account['maskedPan'];
39-
$this->iso4217 = new ISO4217(new AlcoholISO4217());
4037
}
4138

4239
/**
@@ -71,7 +68,7 @@ public function getCurrencyCode(): int
7168

7269
public function getCurrency(): string
7370
{
74-
return $this->iso4217->getByNumeric($this->currencyCode);
71+
return ISO4217::create()->getByNumeric($this->currencyCode);
7572
}
7673

7774
public function getCashbackType(): string

src/Entities/Currency/Currency.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Khandurdyiev\MonoClient\Entities\Currency;
66

7-
use Alcohol\ISO4217 as AlcoholISO4217;
87
use Khandurdyiev\MonoClient\ISO4217;
98
use Carbon\Carbon;
109

@@ -16,7 +15,6 @@ class Currency implements \JsonSerializable
1615
private ?float $rateSell;
1716
private ?float $rateBuy;
1817
private ?float $rateCross;
19-
private ISO4217 $iso4217;
2018

2119
/**
2220
* @param array<string, mixed> $currency
@@ -29,7 +27,6 @@ public function __construct(array $currency)
2927
$this->rateSell = isset($currency['rateSell']) ? (float) $currency['rateSell'] : null;
3028
$this->rateBuy = isset($currency['rateBuy']) ? (float) $currency['rateBuy'] : null;
3129
$this->rateCross = isset($currency['rateCross']) ? (float) $currency['rateCross'] : null;
32-
$this->iso4217 = new ISO4217(new AlcoholISO4217());
3330
}
3431

3532
/**
@@ -54,12 +51,12 @@ public function getCurrencyCodeB(): int
5451

5552
public function getCurrencyA(): string
5653
{
57-
return $this->iso4217->getByNumeric($this->currencyCodeA);
54+
return ISO4217::create()->getByNumeric($this->currencyCodeA);
5855
}
5956

6057
public function getCurrencyB(): string
6158
{
62-
return $this->iso4217->getByNumeric($this->currencyCodeB);
59+
return ISO4217::create()->getByNumeric($this->currencyCodeB);
6360
}
6461

6562
public function getTimestamp(): int

src/Entities/Statement/Statement.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Khandurdyiev\MonoClient\Entities\Statement;
66

7-
use Alcohol\ISO4217 as AlcoholISO4217;
87
use Khandurdyiev\MonoClient\ISO4217;
98
use Khandurdyiev\MonoClient\Utils\Utils;
109

@@ -25,7 +24,6 @@ class Statement implements \JsonSerializable
2524
private string $receiptId;
2625
private string $counterEdrpou;
2726
private string $counterIban;
28-
private ISO4217 $iso4217;
2927

3028
/**
3129
* @param array<string, mixed> $statement
@@ -47,7 +45,6 @@ public function __construct(array $statement)
4745
$this->receiptId = $statement['receiptId'] ?? '';
4846
$this->counterEdrpou = $statement['counterEdrpou'] ?? '';
4947
$this->counterIban = $statement['counterIban'] ?? '';
50-
$this->iso4217 = new ISO4217(new AlcoholISO4217());
5148
}
5249

5350
/**
@@ -102,7 +99,7 @@ public function getCurrencyCode(): int
10299

103100
public function getCurrency(): string
104101
{
105-
return $this->iso4217->getByNumeric($this->currencyCode);
102+
return ISO4217::create()->getByNumeric($this->currencyCode);
106103
}
107104

108105
public function getCommissionRate(): int

src/ISO4217.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88

99
class ISO4217
1010
{
11-
private AlcoholISO4217 $iso4217;
12-
13-
public function __construct(AlcoholISO4217 $iso4217)
11+
public static function create(): ISO4217
1412
{
15-
$this->iso4217 = $iso4217;
13+
return new self();
1614
}
1715

1816
/**
@@ -26,7 +24,7 @@ public function getByNumeric(int $code): string
2624

2725
try {
2826
/** @var string $code */
29-
$code = $this->iso4217->getByNumeric($numeric)['alpha3'];
27+
$code = (new AlcoholISO4217())->getByNumeric($numeric)['alpha3'];
3028

3129
return $code;
3230
} catch (\OutOfBoundsException $exception) {

0 commit comments

Comments
 (0)