private function retrieveGenericMatches($acceptLanguages, &$matches)
    {
        $genericMatches = [];

        foreach ($acceptLanguages as $option) {
            $option  = array_map('trim', explode(';', $option));
            $locale  = $option[0];
            $quality = $this->getQualityFactor($locale, $option);

            // Unweighted values, get high weight by their position in the list
            $quality          = isset($quality) ? $quality : 1000 - count($matches);
            $matches[$locale] = $quality;

            // If for some reason the Accept-Language header only sends language with country we should make
            // the language without country an accepted option, with a value less than it's parent.
            $localeOptions = explode('-', $locale);
            array_pop($localeOptions);

            while ( ! empty($localeOptions)) {
                //The new generic option needs to be slightly less important than it's base
                $quality -= 0.001;
                $opt      = implode('-', $localeOptions);

                if (empty($genericMatches[$opt]) || $genericMatches[$opt] > $quality) {
                    $genericMatches[$opt] = $quality;
                }

                array_pop($localeOptions);
            }
        }

        return $genericMatches;
    }
private function retrieveGenericMatches($acceptLanguages, &$matches)
    {
        $genericMatches = [];

        foreach ($acceptLanguages as $option) {
            $option  = array_map('trim', explode(';', $option));
            $locale  = $option[0];
            $quality = $this->getQualityFactor($locale, $option);

            // Unweighted values, get high weight by their position in the list
            $quality          = isset($quality) ? $quality : 1000 - count($matches);
            $matches[$locale] = $quality;

            // If for some reason the Accept-Language header only sends language with country we should make
            // the language without country an accepted option, with a value less than it's parent.
            $localeOptions = explode('-', $locale);
            array_pop($localeOptions);

            while ( ! empty($localeOptions)) {
                //The new generic option needs to be slightly less important than it's base
                $quality -= 0.001;
                $opt      = implode('-', $localeOptions);

                if (empty($genericMatches[$opt]) || $genericMatches[$opt] > $quality) {
                    $genericMatches[$opt] = $quality;
                }

                array_pop($localeOptions);
            }
        }

        return $genericMatches;
    }
private function retrieveGenericMatches ( $ acceptLanguages , & $ matches ) { $ genericMatches = [ ] ; foreach ( $ acceptLanguages as $ option ) { $ option = array_map ( 'trim' , explode ( ';' , $ option ) ) ; $ locale = $ option [ 0 ] ; $ quality = $ this -> getQualityFactor ( $ locale , $ option ) ; // Unweighted values, get high weight by their position in the list $ quality = isset ( $ quality ) ? $ quality : 1000 - count ( $ matches ) ; $ matches [ $ locale ] = $ quality ; // If for some reason the Accept-Language header only sends language with country we should make // the language without country an accepted option, with a value less than it's parent. $ localeOptions = explode ( '-' , $ locale ) ; array_pop ( $ localeOptions ) ; while ( ! empty ( $ localeOptions ) ) { //The new generic option needs to be slightly less important than it's base $ quality -= 0.001 ; $ opt = implode ( '-' , $ localeOptions ) ; if ( empty ( $ genericMatches [ $ opt ] ) || $ genericMatches [ $ opt ] > $ quality ) { $ genericMatches [ $ opt ] = $ quality ; } array_pop ( $ localeOptions ) ; } } return $ genericMatches ; }
Get the generic matches.

@param  array  $acceptLanguages
@param  array  $matches

@return array
Get the generic matches .