Skip to content

Commit e12bf91

Browse files
committed
psalm-fix
1 parent 7a001dd commit e12bf91

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

phpstan-baseline.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ parameters:
7777

7878
-
7979
message: "#^Cannot call method needs\\(\\) on mixed\\.$#"
80-
count: 4
80+
count: 6
8181
path: src/WalletServiceProvider.php
8282

8383
-

src/Internal/Service/LockService.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@ final class LockService implements LockServiceInterface
2222

2323
private CacheRepository $cache;
2424

25-
private int $seconds;
26-
27-
public function __construct(CacheFactory $cacheFactory)
28-
{
25+
public function __construct(
26+
CacheFactory $cacheFactory,
27+
private int $seconds
28+
) {
2929
$this->cache = $cacheFactory->store(config('wallet.lock.driver', 'array'));
30-
$this->seconds = (int) config('wallet.lock.seconds', 1);
3130
$this->lockedKeys = $cacheFactory->store('array');
3231
}
3332

src/Internal/Service/MathService.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99

1010
final class MathService implements MathServiceInterface
1111
{
12-
private int $scale;
13-
14-
public function __construct()
15-
{
16-
$this->scale = (int) config('wallet.math.scale', 64);
12+
public function __construct(
13+
private int $scale
14+
) {
1715
}
1816

1917
public function add(float|int|string $first, float|int|string $second, ?int $scale = null): string

src/WalletServiceProvider.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,17 @@ private function internal(array $configure): void
216216
$this->app->singleton(DatabaseServiceInterface::class, $configure['database'] ?? DatabaseService::class);
217217
$this->app->singleton(DispatcherServiceInterface::class, $configure['dispatcher'] ?? DispatcherService::class);
218218
$this->app->singleton(JsonServiceInterface::class, $configure['json'] ?? JsonService::class);
219+
220+
$this->app->when($configure['lock'] ?? LockService::class)
221+
->needs('$seconds')
222+
->giveConfig('wallet.lock.seconds', 1);
223+
219224
$this->app->singleton(LockServiceInterface::class, $configure['lock'] ?? LockService::class);
225+
226+
$this->app->when($configure['math'] ?? MathService::class)
227+
->needs('$scale')
228+
->giveConfig('wallet.math.scale', 64);
229+
220230
$this->app->singleton(MathServiceInterface::class, $configure['math'] ?? MathService::class);
221231
$this->app->singleton(StateServiceInterface::class, $configure['state'] ?? StateService::class);
222232
$this->app->singleton(TranslatorServiceInterface::class, $configure['translator'] ?? TranslatorService::class);

0 commit comments

Comments
 (0)