32 $this->formatter = $formatter;
33 $this->currencies = $currencies;
44 if ($valueBase[0] ===
'-') {
46 $valueBase = substr($valueBase, 1);
49 $subunit = $this->currencies->subunitFor($money->
getCurrency());
50 $valueLength = strlen($valueBase);
52 if ($valueLength > $subunit) {
53 $formatted = substr($valueBase, 0, $valueLength - $subunit);
54 $decimalDigits = substr($valueBase, $valueLength - $subunit);
56 if (strlen($decimalDigits) > 0) {
57 $formatted .=
'.'.$decimalDigits;
60 $formatted =
'0.'.str_pad(
'', $subunit - $valueLength,
'0').$valueBase;
63 if ($negative ===
true) {
64 $formatted =
'-'.$formatted;
67 return $this->formatter->formatCurrency($formatted, $money->
getCurrency()->getCode());