kwn/number-to-words

View on GitHub
src/Service/NumberToTripletsConverter.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php

namespace NumberToWords\Service;

class NumberToTripletsConverter
{
    public function convertToTriplets(int $number): array
    {
        $triplets = [];

        while ($number > 0) {
            $triplets[] = $number % 1000;
            $number = (int) ($number / 1000);
        }

        return array_reverse($triplets);
    }
}