Skip to content

Commit 4b43181

Browse files
committed
Refactor
1 parent bae02dc commit 4b43181

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/BrowserLocale.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct($httpAcceptLanguages)
3535
/**
3636
* Get the most preferred locale.
3737
*
38-
* @return Locale|null
38+
* @return \CodeZero\BrowserLocale\Locale|null
3939
*/
4040
public function getLocale()
4141
{
@@ -88,25 +88,25 @@ protected function parseAcceptLanguages($httpAcceptLanguages)
8888
*
8989
* @param string $httpAcceptLanguage
9090
*
91-
* @return Locale|null
91+
* @return \CodeZero\BrowserLocale\Locale|null
9292
*/
9393
protected function parseAcceptLanguage($httpAcceptLanguage)
9494
{
9595
$parts = $this->splitAcceptLanguage($httpAcceptLanguage);
9696

97-
$locale = isset($parts[0]) ? $parts[0] : null;
98-
$weight = isset($parts[1]) ? $parts[1] : null;
97+
$locale = $parts[0] ?? null;
98+
$weight = $parts[1] ?? null;
9999

100-
$localeInstance = null;
101-
102-
if ($locale !== null) {
103-
$localeInstance = new Locale();
104-
$localeInstance->full = $locale;
105-
$localeInstance->language = $this->getLanguage($locale);
106-
$localeInstance->country = $this->getCountry($locale);
107-
$localeInstance->weight = $this->getWeight($weight);
100+
if ($locale === null) {
101+
return null;
108102
}
109103

104+
$localeInstance = new Locale();
105+
$localeInstance->full = $locale;
106+
$localeInstance->language = $this->getLanguage($locale);
107+
$localeInstance->country = $this->getCountry($locale);
108+
$localeInstance->weight = $this->getWeight($weight);
109+
110110
return $localeInstance;
111111
}
112112

0 commit comments

Comments
 (0)