protected function formatInteger($string)
{
$string = (string) $string;
$decimalDigits = $this->formatInfo->DecimalDigits;
//if not decimal digits, assume 0 decimal points.
if (is_int($decimalDigits) && $decimalDigits > 0) {
$string = (string) round(floatval($string), $decimalDigits);
}
$dp = strpos($string, '.');
if (is_int($dp)) {
$string = substr($string, 0, $dp);
}
$integer = '';
$digitSize = $this->formatInfo->getDigitSize();
$string = str_pad($string, $digitSize, '0', STR_PAD_LEFT);
$len = strlen($string);
$groupSeparator = $this->formatInfo->GroupSeparator;
$groupSize = $this->formatInfo->GroupSizes;
$firstGroup = true;
$multiGroup = is_int($groupSize[1]);
$count = 0;
if (is_int($groupSize[0])) {
//now for the integer groupings
for ($i = 0; $i < $len; $i++) {
$char = $string[$len - $i - 1];
if ($multiGroup && $count == 0) {
if ($i != 0 && $i % $groupSize[0] == 0) {
$integer = $groupSeparator . $integer;
$count++;
}
} else {
if ($multiGroup && $count >= 1) {
if ($i != 0 && ($i - $groupSize[0]) % $groupSize[1] == 0) {
$integer = $groupSeparator . $integer;
$count++;
}
} else {
if ($i != 0 && $i % $groupSize[0] == 0) {
$integer = $groupSeparator . $integer;
$count++;
}
}
}
$integer = $char . $integer;
}
} else {
$integer = $string;
}
return $integer;
}