mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-16 01:06:46 +00:00
chore: code cleanup.
This commit is contained in:
@@ -46,6 +46,18 @@ class AmountFormat extends AbstractExtension
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFunctions(): array
|
||||
{
|
||||
return [
|
||||
$this->formatAmountByAccount(),
|
||||
$this->formatAmountBySymbol(),
|
||||
$this->formatAmountByCurrency(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TwigFilter
|
||||
*/
|
||||
@@ -62,34 +74,6 @@ class AmountFormat extends AbstractExtension
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TwigFilter
|
||||
*/
|
||||
protected function formatAmountPlain(): TwigFilter
|
||||
{
|
||||
return new TwigFilter(
|
||||
'formatAmountPlain',
|
||||
static function (string $string): string {
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
|
||||
return app('amount')->formatAnything($currency, $string, false);
|
||||
},
|
||||
['is_safe' => ['html']]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFunctions(): array
|
||||
{
|
||||
return [
|
||||
$this->formatAmountByAccount(),
|
||||
$this->formatAmountBySymbol(),
|
||||
$this->formatAmountByCurrency(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Will format the amount by the currency related to the given account.
|
||||
*
|
||||
@@ -112,6 +96,24 @@ class AmountFormat extends AbstractExtension
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Will format the amount by the currency related to the given account.
|
||||
*
|
||||
* @return TwigFunction
|
||||
*/
|
||||
protected function formatAmountByCurrency(): TwigFunction
|
||||
{
|
||||
return new TwigFunction(
|
||||
'formatAmountByCurrency',
|
||||
static function (TransactionCurrency $currency, string $amount, bool $coloured = null): string {
|
||||
$coloured = $coloured ?? true;
|
||||
|
||||
return app('amount')->formatAnything($currency, $amount, $coloured);
|
||||
},
|
||||
['is_safe' => ['html']]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Will format the amount by the currency related to the given account.
|
||||
*
|
||||
@@ -135,18 +137,16 @@ class AmountFormat extends AbstractExtension
|
||||
}
|
||||
|
||||
/**
|
||||
* Will format the amount by the currency related to the given account.
|
||||
*
|
||||
* @return TwigFunction
|
||||
* @return TwigFilter
|
||||
*/
|
||||
protected function formatAmountByCurrency(): TwigFunction
|
||||
protected function formatAmountPlain(): TwigFilter
|
||||
{
|
||||
return new TwigFunction(
|
||||
'formatAmountByCurrency',
|
||||
static function (TransactionCurrency $currency, string $amount, bool $coloured = null): string {
|
||||
$coloured = $coloured ?? true;
|
||||
return new TwigFilter(
|
||||
'formatAmountPlain',
|
||||
static function (string $string): string {
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
|
||||
return app('amount')->formatAnything($currency, $amount, $coloured);
|
||||
return app('amount')->formatAnything($currency, $string, false);
|
||||
},
|
||||
['is_safe' => ['html']]
|
||||
);
|
||||
|
Reference in New Issue
Block a user