public function getBestLanguageMatch(array $supportedLanguages, array $languageHeaders): ?string
    {
        usort($languageHeaders, [$this, 'compareAcceptLanguageHeaders']);
        $rankedLanguageHeaders = array_filter($languageHeaders, [$this, 'filterZeroScores']);
        $rankedLanguageHeaderValues = $this->getLanguageValuesFromHeaders($rankedLanguageHeaders);

        foreach ($rankedLanguageHeaderValues as $language) {
            $languageParts = explode('-', $language);

            // Progressively truncate this language tag and try to match a supported language
            do {
                foreach ($supportedLanguages as $supportedLanguage) {
                    if ($language === '*' || implode('-', $languageParts) === $supportedLanguage) {
                        return $supportedLanguage;
                    }
                }

                array_pop($languageParts);
            } while (count($languageParts) > 0);
        }

        return null;
    }