app/Services/RomanNumeralsService.php
public function numberToRomanNumerals(int $number): string
    {
        if ($number < 1) {
            // Cannot convert zero/negative numbers
            return (string) $number;
        }
        $roman = '';
        foreach (self::ROMAN_NUMERALS as $key => $value) {
            while ($number >= $key) {
                $roman  .= $value;
                $number -= $key;
            }
        }

        return $roman;
    }
public function numberToRomanNumerals(int $number): string
    {
        if ($number < 1) {
            // Cannot convert zero/negative numbers
            return (string) $number;
        }
        $roman = '';
        foreach (self::ROMAN_NUMERALS as $key => $value) {
            while ($number >= $key) {
                $roman  .= $value;
                $number -= $key;
            }
        }

        return $roman;
    }
public function numberToRomanNumerals ( int $ number ) : string { if ( $ number < 1 ) { // Cannot convert zero/negative numbers return ( string ) $ number ; } $ roman = '' ; foreach ( self :: ROMAN_NUMERALS as $ key => $ value ) { while ( $ number >= $ key ) { $ roman .= $ value ; $ number -= $ key ; } } return $ roman ; }
Convert a decimal number to roman numerals

@param int $number

@return string
Convert a decimal number to roman numerals