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

chore: small improvements #169

Merged
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
7 changes: 1 addition & 6 deletions src/Money/MoneyManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@
use Money\Money;

/**
* Class MoneyManager.
*
* @author levan
*/
class MoneyManager implements MoneyManagerInterface
{
/**
* MoneyManager constructor.
*/
public function __construct(protected string $referenceCurrencyCode, protected int $decimals = 2)
{
}
Expand All @@ -29,10 +24,10 @@
if (is_null($currencyCode)) {
$currencyCode = $this->referenceCurrencyCode;
}
$currency = new Currency($currencyCode);

Check failure on line 27 in src/Money/MoneyManager.php

View workflow job for this annotation

GitHub Actions / psalm

ArgumentTypeCoercion

src/Money/MoneyManager.php:27:34: ArgumentTypeCoercion: Argument 1 of Money\Currency::__construct expects non-empty-string, but parent type string provided (see https://psalm.dev/193)
$amountAsInt = $floatAmount * 10 ** $this->decimals;
$amountAsInt = round($amountAsInt);
$amountAsInt = intval($amountAsInt);
$amountAsInt = (int)$amountAsInt;

return new Money($amountAsInt, $currency);
}
Expand Down
3 changes: 0 additions & 3 deletions src/Money/MoneyManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

use Money\Money;

/**
* Interface MoneyManagerInterface.
*/
interface MoneyManagerInterface
{
/**
Expand Down
2 changes: 0 additions & 2 deletions src/MoneyException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
namespace Tbbc\MoneyBundle;

/**
* Class MoneyException.
*
* @author Philippe Le Van.
*/
class MoneyException extends \Exception
Expand Down
2 changes: 0 additions & 2 deletions src/Pair/PairManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
use Tbbc\MoneyBundle\TbbcMoneyEvents;

/**
* Class PairManager.
*
* @author Philippe Le Van.
*/
class PairManager implements PairManagerInterface, Exchange
Expand All @@ -42,7 +40,7 @@
{
$converter = new Converter($this->currencies, $this);

return $converter->convert($amount, new Currency($currencyCode));

Check failure on line 43 in src/Pair/PairManager.php

View workflow job for this annotation

GitHub Actions / psalm

ArgumentTypeCoercion

src/Pair/PairManager.php:43:58: ArgumentTypeCoercion: Argument 1 of Money\Currency::__construct expects non-empty-string, but parent type string provided (see https://psalm.dev/193)
}

/**
Expand All @@ -60,7 +58,7 @@
*/
public function saveRatio(string $currencyCode, float $ratio): void
{
$currency = new Currency($currencyCode);

Check failure on line 61 in src/Pair/PairManager.php

View workflow job for this annotation

GitHub Actions / psalm

ArgumentTypeCoercion

src/Pair/PairManager.php:61:34: ArgumentTypeCoercion: Argument 1 of Money\Currency::__construct expects non-empty-string, but parent type string provided (see https://psalm.dev/193)

if ($ratio <= 0) {
throw new MoneyException('ratio has to be strictly positive');
Expand All @@ -87,7 +85,7 @@
*/
public function getRelativeRatio(string $referenceCurrencyCode, string $currencyCode): float
{
$currency = new Currency($currencyCode);

Check failure on line 88 in src/Pair/PairManager.php

View workflow job for this annotation

GitHub Actions / psalm

ArgumentTypeCoercion

src/Pair/PairManager.php:88:34: ArgumentTypeCoercion: Argument 1 of Money\Currency::__construct expects non-empty-string, but parent type string provided (see https://psalm.dev/193)
$referenceCurrency = new Currency($referenceCurrencyCode);
if ($currencyCode === $referenceCurrencyCode) {
return 1.0;
Expand Down
3 changes: 0 additions & 3 deletions src/PairHistory/PairHistoryManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

use Tbbc\MoneyBundle\Pair\SaveRatioEvent;

/**
* Interface PairHistoryManagerInterface.
*/
interface PairHistoryManagerInterface
{
/**
Expand Down
3 changes: 0 additions & 3 deletions src/TbbcMoneyBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
use Tbbc\MoneyBundle\DependencyInjection\Compiler\RatioProviderCompilerPass;
use Tbbc\MoneyBundle\DependencyInjection\Compiler\StorageCompilerPass;

/**
* Class TbbcMoneyBundle.
*/
class TbbcMoneyBundle extends Bundle
{
public function build(ContainerBuilder $container): void
Expand Down
3 changes: 0 additions & 3 deletions src/TbbcMoneyEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

namespace Tbbc\MoneyBundle;

/**
* Class TbbcMoneyEvents.
*/
class TbbcMoneyEvents
{
public const AFTER_RATIO_SAVE = 'tbbc_money.after_ratio_save';
Expand Down
3 changes: 3 additions & 0 deletions src/Twig/Extension/CurrencyExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public function __construct(protected MoneyFormatter $moneyFormatter)
{
}

/**
* {@inheritDoc}
*/
public function getFilters(): array
{
return [
Expand Down
Loading