Browse Source

add formatKVA filter

main
ghost 9 months ago
parent
commit
dcf7fd96c7
  1. 23
      src/Twig/AppExtension.php

23
src/Twig/AppExtension.php

@ -45,6 +45,13 @@ class AppExtension extends AbstractExtension @@ -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 @@ -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…
Cancel
Save