public static function toWesternYear($year)
    {
        if (Analyzer::hasKanji($year)) {
            $key = 'kanji';
            $eraName = Helper::extractKanji($year);
            $eraName = $eraName[0];
            $eraValue = (int)Helper::subString($year, Analyzer::length($eraName), Analyzer::length($year));
        } elseif (Analyzer::hasHiragana($year)) {
            $key = 'kana';
            $eraName = Helper::extractHiragana($year);
            $eraName = $eraName[0];
            $eraValue = (int)Helper::subString($year, Analyzer::length($eraName), Analyzer::length($year));
        } else {
            $key = 'romaji';
            $year = ucfirst(mb_strtolower($year, 'UTF-8')); // Change case to match `$mapEras`
            $parts = explode(' ', $year);
            $eraName = $parts[0];
            $eraValue = (int)$parts[1];
        }

        if (empty($eraName) || empty($eraValue)) {
            throw new Exception('Invalid year ' . $year);
        }
        $max = count(self::$mapEras);
        $westernYears = array();
        for ($i = 0; $i < $max; $i++) {
            $era = self::$mapEras[$i];
            $overflown = false;
            if ($era[$key] == $eraName) {
                $eraStart = $era['year'];
                $westernYear = $eraStart + $eraValue - 1;
                if ($i < $max - 1) {
                    $nextEra = self::$mapEras[$i + 1];
                    $nextEraYear = $nextEra['year'];
                    if ($westernYear > $nextEraYear) {
                        $overflown = true;
                    }
                }
                $westernYears[] = array('value' => $westernYear, 'overflown' => $overflown);
            }
        }
        $results = array();
        foreach ($westernYears as $westernYear) {
            if (!$westernYear['overflown']) {
                $results[] = $westernYear['value'];
            }
        }
        if (empty($results)) {
            throw new Exception('Year ' . $year . ' is invalid');
        } elseif (count($results) == 1) {
            return $results[0];
        } else {
            return $results;
        }
    }