Issues (43)

Classes/Service/LanguageService.php (1 issue)

Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lochmueller\LanguageDetection\Service;
6
7
use Locale;
8
use ResourceBundle;
9
10
class LanguageService
11
{
12
    public function getLanguageByCountry(string $country): string
13
    {
14
        /** @var ResourceBundle $subtags */
15
        $subtags = ResourceBundle::create('likelySubtags', 'ICUDATA', false);
16
        $dummy = 'und_' . strtoupper($country);
17
        $locale = $subtags->get($dummy) ?: $subtags->get('und');
18
19
        return Locale::getPrimaryLanguage($locale);
0 ignored issues
show
Bug Best Practice introduced by
The expression return Locale::getPrimaryLanguage($locale) could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
20
    }
21
}
22