Skip to content

Commit

Permalink
Merge pull request #834 from bavix/11.x-831-the-buy-function-only-acc…
Browse files Browse the repository at this point in the history
…epts-integer-data

[11.x] add FormatterServiceInterface
  • Loading branch information
rez1dent3 authored Jan 5, 2024
2 parents 15e7ee1 + 873bbc2 commit 437c21a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
use Bavix\Wallet\Services\DiscountService;
use Bavix\Wallet\Services\EagerLoaderService;
use Bavix\Wallet\Services\ExchangeService;
use Bavix\Wallet\Services\FormatterService;

Check warning on line 47 in config/config.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'FormatterService'
use Bavix\Wallet\Services\PrepareService;
use Bavix\Wallet\Services\PurchaseService;
use Bavix\Wallet\Services\RegulatorService;
Expand Down Expand Up @@ -110,6 +111,7 @@
'discount' => DiscountService::class,
'eager_loader' => EagerLoaderService::class,
'exchange' => ExchangeService::class,
'formatter' => FormatterService::class,

Check warning on line 114 in config/config.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'FormatterService'
'prepare' => PrepareService::class,
'purchase' => PurchaseService::class,
'tax' => TaxService::class,
Expand Down
9 changes: 5 additions & 4 deletions src/Traits/HasWalletFloat.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Bavix\Wallet\Models\Transaction;
use Bavix\Wallet\Models\Transfer;
use Bavix\Wallet\Services\CastServiceInterface;
use Bavix\Wallet\Services\FormatterServiceInterface;

Check warning on line 18 in src/Traits/HasWalletFloat.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'FormatterServiceInterface'
use Illuminate\Database\RecordsNotFoundException;

/**
Expand Down Expand Up @@ -147,12 +148,12 @@ public function forceTransferFloat(

public function getBalanceFloatAttribute(): string
{
$math = app(MathServiceInterface::class);
$wallet = app(CastServiceInterface::class)->getWallet($this);
$decimalPlacesValue = $wallet->decimal_places;
$decimalPlaces = $math->powTen($decimalPlacesValue);

return $math->div($wallet->getBalanceAttribute(), $decimalPlaces, $decimalPlacesValue);
return app(FormatterServiceInterface::class)->floatValue(

Check warning on line 153 in src/Traits/HasWalletFloat.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'FormatterServiceInterface'
$wallet->getBalanceAttribute(),
$wallet->decimal_places,
);
}

public function getBalanceFloatNumAttribute(): float
Expand Down
4 changes: 4 additions & 0 deletions src/WalletServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
use Bavix\Wallet\Services\EagerLoaderServiceInterface;
use Bavix\Wallet\Services\ExchangeService;
use Bavix\Wallet\Services\ExchangeServiceInterface;
use Bavix\Wallet\Services\FormatterService;

Check warning on line 95 in src/WalletServiceProvider.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'FormatterService'
use Bavix\Wallet\Services\FormatterServiceInterface;

Check warning on line 96 in src/WalletServiceProvider.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'FormatterServiceInterface'
use Bavix\Wallet\Services\PrepareService;
use Bavix\Wallet\Services\PrepareServiceInterface;
use Bavix\Wallet\Services\PurchaseService;
Expand Down Expand Up @@ -274,6 +276,7 @@ private function services(array $configure, array $cache): void
$configure['eager_loader'] ?? EagerLoaderService::class
);
$this->app->singleton(ExchangeServiceInterface::class, $configure['exchange'] ?? ExchangeService::class);
$this->app->singleton(FormatterServiceInterface::class, $configure['formatter'] ?? FormatterService::class);

Check failure on line 279 in src/WalletServiceProvider.php

View workflow job for this annotation

GitHub Actions / phpstan

Class Bavix\Wallet\Services\FormatterService not found.

Check failure on line 279 in src/WalletServiceProvider.php

View workflow job for this annotation

GitHub Actions / phpstan

Class Bavix\Wallet\Services\FormatterServiceInterface not found.

Check warning on line 279 in src/WalletServiceProvider.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'FormatterService'

Check warning on line 279 in src/WalletServiceProvider.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'FormatterServiceInterface'
$this->app->singleton(PrepareServiceInterface::class, $configure['prepare'] ?? PrepareService::class);
$this->app->singleton(PurchaseServiceInterface::class, $configure['purchase'] ?? PurchaseService::class);
$this->app->singleton(TaxServiceInterface::class, $configure['tax'] ?? TaxService::class);
Expand Down Expand Up @@ -466,6 +469,7 @@ private function servicesProviders(): array
DiscountServiceInterface::class,
EagerLoaderServiceInterface::class,
ExchangeServiceInterface::class,
FormatterServiceInterface::class,

Check failure on line 472 in src/WalletServiceProvider.php

View workflow job for this annotation

GitHub Actions / phpstan

Class Bavix\Wallet\Services\FormatterServiceInterface not found.

Check warning on line 472 in src/WalletServiceProvider.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'FormatterServiceInterface'
PrepareServiceInterface::class,
PurchaseServiceInterface::class,
TaxServiceInterface::class,
Expand Down

0 comments on commit 437c21a

Please sign in to comment.