diff --git a/src/Twig/AppExtension.php b/src/Twig/AppExtension.php index b1c9111..ea43d34 100644 --- a/src/Twig/AppExtension.php +++ b/src/Twig/AppExtension.php @@ -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