Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

psalm-fix #585

Merged
merged 1 commit into from
Oct 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ parameters:

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

-
Expand Down
9 changes: 4 additions & 5 deletions src/Internal/Service/LockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ final class LockService implements LockServiceInterface

private CacheRepository $cache;

private int $seconds;

public function __construct(CacheFactory $cacheFactory)
{
public function __construct(
CacheFactory $cacheFactory,
private int $seconds
) {
$this->cache = $cacheFactory->store(config('wallet.lock.driver', 'array'));
$this->seconds = (int) config('wallet.lock.seconds', 1);
$this->lockedKeys = $cacheFactory->store('array');
}

Expand Down
8 changes: 3 additions & 5 deletions src/Internal/Service/MathService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@

final class MathService implements MathServiceInterface
{
private int $scale;

public function __construct()
{
$this->scale = (int) config('wallet.math.scale', 64);
public function __construct(
private int $scale
) {
}

public function add(float|int|string $first, float|int|string $second, ?int $scale = null): string
Expand Down
10 changes: 10 additions & 0 deletions src/WalletServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,17 @@ private function internal(array $configure): void
$this->app->singleton(DatabaseServiceInterface::class, $configure['database'] ?? DatabaseService::class);
$this->app->singleton(DispatcherServiceInterface::class, $configure['dispatcher'] ?? DispatcherService::class);
$this->app->singleton(JsonServiceInterface::class, $configure['json'] ?? JsonService::class);

$this->app->when($configure['lock'] ?? LockService::class)
->needs('$seconds')
->giveConfig('wallet.lock.seconds', 1);

$this->app->singleton(LockServiceInterface::class, $configure['lock'] ?? LockService::class);

$this->app->when($configure['math'] ?? MathService::class)
->needs('$scale')
->giveConfig('wallet.math.scale', 64);

$this->app->singleton(MathServiceInterface::class, $configure['math'] ?? MathService::class);
$this->app->singleton(StateServiceInterface::class, $configure['state'] ?? StateService::class);
$this->app->singleton(TranslatorServiceInterface::class, $configure['translator'] ?? TranslatorService::class);
Expand Down