Skip to content

Commit 82f3f19

Browse files
committed
fix phpstan
1 parent ac2b127 commit 82f3f19

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

src/Internal/Dto/OptionDto.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
final class OptionDto implements OptionDtoInterface
1111
{
1212
public function __construct(
13-
private ?array $meta = null
13+
private ?array $meta
1414
) {
1515
}
1616

src/Objects/Extra.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ final class Extra implements ExtraDtoInterface
1414

1515
public function __construct(array|OptionDtoInterface|null $deposit, array|OptionDtoInterface|null $withdraw)
1616
{
17-
$this->deposit = new Option($deposit);
18-
$this->withdraw = new Option($withdraw);
17+
$this->deposit = $deposit instanceof OptionDtoInterface ? $deposit : new Option($deposit);
18+
$this->withdraw = $withdraw instanceof OptionDtoInterface ? $withdraw : new Option($withdraw);
1919
}
2020

2121
public function getDepositExtra(): OptionDtoInterface

src/Objects/Option.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
final class Option implements OptionDtoInterface
1010
{
1111
public function __construct(
12-
private ?array $meta = null
12+
private ?array $meta
1313
) {
1414
}
1515

src/Services/CommonServiceLegacy.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,7 @@ public function applyTransfers(array $objects): array
9292
$deposit = $transactions[$object->getDepositDto()->getUuid()] ?? null;
9393
assert($deposit !== null);
9494

95-
$links[$deposit->getKey()] = $deposit;
96-
$links[$withdraw->getKey()] = $withdraw;
97-
98-
$transfers[] = $this->transferDtoAssembler->create(
95+
$transfer = $this->transferDtoAssembler->create(
9996
$deposit->getKey(),
10097
$withdraw->getKey(),
10198
$object->getStatus(),
@@ -104,14 +101,17 @@ public function applyTransfers(array $objects): array
104101
$object->getDiscount(),
105102
$object->getFee()
106103
);
104+
105+
$transfers[] = $transfer;
106+
$links[$transfer->getUuid()] = [
107+
'deposit' => $deposit,
108+
'withdraw' => $withdraw,
109+
];
107110
}
108111

109112
$models = $this->atmService->makeTransfers($transfers);
110113
foreach ($models as $model) {
111-
if (isset($links[$model->deposit_id], $links[$model->withdraw_id])) {
112-
$model->setRelation('withdraw', $links[$model->withdraw_id]);
113-
$model->setRelation('deposit', $links[$model->deposit_id]);
114-
}
114+
$model->setRelations($links[$model->uuid] ?? []);
115115
}
116116

117117
return $models;
@@ -128,7 +128,7 @@ public function makeTransaction(
128128
Wallet $wallet,
129129
string $type,
130130
$amount,
131-
array|null|ExtraDtoInterface $meta,
131+
?array $meta,
132132
bool $confirmed = true
133133
): Transaction {
134134
assert(in_array($type, [Transaction::TYPE_DEPOSIT, Transaction::TYPE_WITHDRAW], true));
@@ -141,7 +141,7 @@ public function makeTransaction(
141141

142142
$transactions = $this->applyTransactions([
143143
$dto->getWalletId() => $wallet,
144-
], [$dto],);
144+
], [$dto]);
145145

146146
return current($transactions);
147147
}

src/Traits/HasWallet.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Bavix\Wallet\Traits;
66

7+
use function app;
78
use Bavix\Wallet\Exceptions\AmountInvalid;
89
use Bavix\Wallet\Exceptions\BalanceIsEmpty;
910
use Bavix\Wallet\Exceptions\InsufficientFunds;
@@ -21,12 +22,11 @@
2122
use Bavix\Wallet\Services\CommonServiceLegacy;
2223
use Bavix\Wallet\Services\ConsistencyServiceInterface;
2324
use Bavix\Wallet\Services\RegulatorServiceInterface;
25+
use function config;
2426
use Illuminate\Database\Eloquent\Relations\HasMany;
2527
use Illuminate\Database\Eloquent\Relations\MorphMany;
2628
use Illuminate\Database\RecordsNotFoundException;
2729
use Illuminate\Support\Collection;
28-
use function app;
29-
use function config;
3030

3131
/**
3232
* Trait HasWallet.

0 commit comments

Comments
 (0)