app/Services/RomanNumeralsService.php
public function romanNumeralsToNumber(string $roman): int
    {
        $num = 0;
        foreach (self::ROMAN_NUMERALS as $key => $value) {
            while (strpos($roman, $value) === 0) {
                $num += $key;
                $roman = substr($roman, strlen($value));
            }
        }

        return $num;
    }
public function romanNumeralsToNumber(string $roman): int
    {
        $num = 0;
        foreach (self::ROMAN_NUMERALS as $key => $value) {
            while (strpos($roman, $value) === 0) {
                $num += $key;
                $roman = substr($roman, strlen($value));
            }
        }

        return $num;
    }
public function romanNumeralsToNumber ( string $ roman ) : int { $ num = 0 ; foreach ( self :: ROMAN_NUMERALS as $ key => $ value ) { while ( strpos ( $ roman , $ value ) === 0 ) { $ num += $ key ; $ roman = substr ( $ roman , strlen ( $ value ) ) ; } } return $ num ; }
Convert a roman numeral to decimal

@param string $roman

@return int
Convert a roman numeral to decimal