LexwareMoney.php
Pfad: src/Infrastructure/Rechnung/LexwareMoney.php
Ext: php
Größe: 538 Bytes
Geändert: 2026-07-16 17:41:12+02
<?php
declare(strict_types=1);
namespace Demo\Infrastructure\Rechnung;
use Demo\Domain\Rechnung\Amount;
final class LexwareMoney
{
public static function format(string $value): string
{
$decimal = Amount::decimal($value);
[$whole, $fraction] = explode('.', $decimal);
$cents = (int) substr($fraction, 0, 2) + ((int) $fraction[2] >= 5 ? 1 : 0);
$wholeNumber = (int) $whole + intdiv($cents, 100);
return $wholeNumber . '.' . str_pad((string) ($cents % 100), 2, '0', STR_PAD_LEFT);
}
}