mirror of
https://github.com/kevachat/webapp.git
synced 2025-09-01 00:21:49 +00:00
add formatKVA filter
This commit is contained in:
parent
3c4e74724c
commit
dcf7fd96c7
@ -45,6 +45,13 @@ class AppExtension extends AbstractExtension
|
|||||||
'formatBytes'
|
'formatBytes'
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
new TwigFilter(
|
||||||
|
'format_kva',
|
||||||
|
[
|
||||||
|
$this,
|
||||||
|
'formatKVA'
|
||||||
|
]
|
||||||
|
),
|
||||||
new TwigFilter(
|
new TwigFilter(
|
||||||
'message_to_markdown',
|
'message_to_markdown',
|
||||||
[
|
[
|
||||||
@ -247,6 +254,22 @@ class AppExtension extends AbstractExtension
|
|||||||
return sprintf("%.{$precision}f", $bytes / pow(1024, $factor)) . ' ' . @$size[$factor];
|
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(
|
public function messageToMarkdown(
|
||||||
string $text
|
string $text
|
||||||
): string
|
): string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user