Skip to content

Commit f2ca3bb

Browse files
committed
Revert "draft config"
This reverts commit 0a42314.
1 parent 7772d6a commit f2ca3bb

File tree

14 files changed

+28
-102
lines changed

14 files changed

+28
-102
lines changed

config/config.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Bavix\Wallet\Internal\Repository\TransferRepository;
2020
use Bavix\Wallet\Internal\Repository\WalletRepository;
2121
use Bavix\Wallet\Internal\Service\ClockService;
22-
use Bavix\Wallet\Internal\Service\ConfigService;
2322
use Bavix\Wallet\Internal\Service\DatabaseService;
2423
use Bavix\Wallet\Internal\Service\DispatcherService;
2524
use Bavix\Wallet\Internal\Service\JsonService;
@@ -81,7 +80,6 @@
8180
*/
8281
'internal' => [
8382
'clock' => ClockService::class,
84-
'config' => ConfigService::class,
8583
'database' => DatabaseService::class,
8684
'dispatcher' => DispatcherService::class,
8785
'json' => JsonService::class,

deptrac.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ parameters:
201201
- RepositoryInterface
202202
- TransformInterface
203203
- InternalException
204-
- ServiceInterface # json&config service only
204+
- ServiceInterface # json service only
205205
- QueryInterface
206206
- DtoInterface
207207
- UIException

src/Internal/Repository/WalletRepository.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66

77
use Bavix\Wallet\Internal\Exceptions\ExceptionInterface;
88
use Bavix\Wallet\Internal\Exceptions\ModelNotFoundException;
9-
use Bavix\Wallet\Internal\Service\ConfigServiceInterface;
109
use Bavix\Wallet\Models\Wallet;
1110
use Illuminate\Database\Eloquent\ModelNotFoundException as EloquentModelNotFoundException;
1211

1312
final class WalletRepository implements WalletRepositoryInterface
1413
{
1514
public function __construct(
16-
private ConfigServiceInterface $configService,
1715
private Wallet $wallet
1816
) {
1917
}
@@ -93,7 +91,7 @@ public function getBySlug(string $holderType, int|string $holderId, string $slug
9391
public function findDefaultAll(string $holderType, array $holderIds): array
9492
{
9593
return $this->wallet->newQuery()
96-
->where('slug', $this->configService->getString('wallet.wallet.default.slug', 'default'))
94+
->where('slug', config('wallet.wallet.default.slug', 'default'))
9795
->where('holder_type', $holderType)
9896
->whereIn('holder_id', $holderIds)
9997
->get()

src/Internal/Service/ConfigService.php

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/Internal/Service/ConfigServiceInterface.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/Models/Transaction.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
namespace Bavix\Wallet\Models;
66

77
use Bavix\Wallet\Interfaces\Wallet;
8-
use Bavix\Wallet\Internal\Service\ConfigServiceInterface;
98
use Bavix\Wallet\Internal\Service\MathServiceInterface;
109
use Bavix\Wallet\Models\Wallet as WalletModel;
1110
use Bavix\Wallet\Services\CastServiceInterface;
11+
use function config;
1212
use Illuminate\Database\Eloquent\Model;
1313
use Illuminate\Database\Eloquent\Relations\BelongsTo;
1414
use Illuminate\Database\Eloquent\Relations\MorphTo;
@@ -61,7 +61,7 @@ class Transaction extends Model
6161
public function getTable(): string
6262
{
6363
if ((string) $this->table === '') {
64-
$this->table = app(ConfigServiceInterface::class)->getString('wallet.transaction.table', 'transactions');
64+
$this->table = config('wallet.transaction.table', 'transactions');
6565
}
6666

6767
return parent::getTable();
@@ -74,9 +74,7 @@ public function payable(): MorphTo
7474

7575
public function wallet(): BelongsTo
7676
{
77-
return $this->belongsTo(
78-
app(ConfigServiceInterface::class)->getClass('wallet.wallet.model', WalletModel::class)
79-
);
77+
return $this->belongsTo(config('wallet.wallet.model', WalletModel::class));
8078
}
8179

8280
public function getAmountIntAttribute(): int

src/Models/Transfer.php

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

55
namespace Bavix\Wallet\Models;
66

7-
use Bavix\Wallet\Internal\Service\ConfigServiceInterface;
7+
use function config;
88
use Illuminate\Database\Eloquent\Model;
99
use Illuminate\Database\Eloquent\Relations\BelongsTo;
1010
use Illuminate\Database\Eloquent\Relations\MorphTo;
@@ -67,7 +67,7 @@ class Transfer extends Model
6767
public function getTable(): string
6868
{
6969
if ((string) $this->table === '') {
70-
$this->table = app(ConfigServiceInterface::class)->getString('wallet.transfer.table', 'transfers');
70+
$this->table = config('wallet.transfer.table', 'transfers');
7171
}
7272

7373
return parent::getTable();

src/Models/Wallet.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Bavix\Wallet\Internal\Exceptions\ExceptionInterface;
1414
use Bavix\Wallet\Internal\Exceptions\LockProviderNotFoundException;
1515
use Bavix\Wallet\Internal\Exceptions\TransactionFailedException;
16-
use Bavix\Wallet\Internal\Service\ConfigServiceInterface;
1716
use Bavix\Wallet\Internal\Service\MathServiceInterface;
1817
use Bavix\Wallet\Internal\Service\UuidFactoryServiceInterface;
1918
use Bavix\Wallet\Services\AtomicServiceInterface;
@@ -22,6 +21,7 @@
2221
use Bavix\Wallet\Traits\CanExchange;
2322
use Bavix\Wallet\Traits\CanPayFloat;
2423
use Bavix\Wallet\Traits\HasGift;
24+
use function config;
2525
use Illuminate\Database\Eloquent\Model;
2626
use Illuminate\Database\Eloquent\Relations\MorphTo;
2727
use Illuminate\Database\RecordsNotFoundException;
@@ -83,7 +83,7 @@ class Wallet extends Model implements Customer, WalletFloat, Confirmable, Exchan
8383
public function getTable(): string
8484
{
8585
if ((string) $this->table === '') {
86-
$this->table = app(ConfigServiceInterface::class)->getString('wallet.wallet.table', 'wallets');
86+
$this->table = config('wallet.wallet.table', 'wallets');
8787
}
8888

8989
return parent::getTable();

src/Services/AtomicServiceInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ interface AtomicServiceInterface
1414
{
1515
/**
1616
* @template T
17+
* @param Wallet $object
1718
* @param callable(): T $callback
1819
* @return T
1920
*

src/Services/WalletService.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Bavix\Wallet\Internal\Assembler\WalletCreatedEventAssemblerInterface;
88
use Bavix\Wallet\Internal\Exceptions\ModelNotFoundException;
99
use Bavix\Wallet\Internal\Repository\WalletRepositoryInterface;
10-
use Bavix\Wallet\Internal\Service\ConfigServiceInterface;
1110
use Bavix\Wallet\Internal\Service\DispatcherServiceInterface;
1211
use Bavix\Wallet\Internal\Service\UuidFactoryServiceInterface;
1312
use Bavix\Wallet\Models\Wallet;
@@ -22,15 +21,14 @@ public function __construct(
2221
private WalletCreatedEventAssemblerInterface $walletCreatedEventAssembler,
2322
private UuidFactoryServiceInterface $uuidFactoryService,
2423
private DispatcherServiceInterface $dispatcherService,
25-
private WalletRepositoryInterface $walletRepository,
26-
private ConfigServiceInterface $configService
24+
private WalletRepositoryInterface $walletRepository
2725
) {
2826
}
2927

3028
public function create(Model $model, array $data): Wallet
3129
{
3230
$wallet = $this->walletRepository->create(array_merge(
33-
$this->configService->getArray('wallet.wallet.creating'),
31+
config('wallet.wallet.creating', []),
3432
[
3533
'uuid' => $this->uuidFactoryService->uuid4(),
3634
],

0 commit comments

Comments
 (0)