mirror of
https://github.com/kevachat/webapp.git
synced 2025-03-10 04:21:01 +00:00
add formatKVA filter
This commit is contained in:
parent
3c4e74724c
commit
dcf7fd96c7
@ -45,6 +45,13 @@ class AppExtension extends AbstractExtension
|
||||
'formatBytes'
|
||||
]
|
||||
),
|
||||
new TwigFilter(
|
||||
'format_kva',
|
||||
[
|
||||
$this,
|
||||
'formatKVA'
|
||||
]
|
||||
),
|
||||
new TwigFilter(
|
||||
'message_to_markdown',
|
||||
[
|
||||
@ -247,6 +254,22 @@ class AppExtension extends AbstractExtension
|
||||
return sprintf("%.{$precision}f", $bytes / pow(1024, $factor)) . ' ' . @$size[$factor];
|
||||
}
|
||||
|
||||
public function formatKVA(
|
||||
float $amount,
|
||||
?int $precision = 8,
|
||||
?string $postfix = 'KVA'
|
||||
): string
|
||||
{
|
||||
return sprintf(
|
||||
'%s %s',
|
||||
round(
|
||||
$amount,
|
||||
$precision
|
||||
),
|
||||
$postfix
|
||||
);
|
||||
}
|
||||
|
||||
public function messageToMarkdown(
|
||||
string $text
|
||||
): string
|
||||
|
Loading…
x
Reference in New Issue
Block a user