@@ -12,6 +12,13 @@ class BrowserLocale
12
12
*/
13
13
protected $ locales = [];
14
14
15
+ /**
16
+ * Supported filters for getLocales().
17
+ *
18
+ * @var array
19
+ */
20
+ protected $ filters = ['full ' , 'language ' , 'country ' , 'weight ' ];
21
+
15
22
/**
16
23
* Create a new BrowserLocale instance.
17
24
*
@@ -32,7 +39,7 @@ public function __construct($httpAcceptLanguages)
32
39
*/
33
40
public function getLocale ()
34
41
{
35
- return isset ( $ this ->locales [0 ]) ? $ this -> locales [ 0 ] : null ;
42
+ return $ this ->locales [0 ] ?? null ;
36
43
}
37
44
38
45
/**
@@ -41,7 +48,7 @@ public function getLocale()
41
48
* If a property filter is specified, a flattened array of locale information,
42
49
* containing only the requested property values will be returned instead.
43
50
*
44
- * @param string $propertyFilter full|language|country|weight
51
+ * @param string $propertyFilter
45
52
*
46
53
* @return array
47
54
*/
@@ -142,7 +149,7 @@ protected function splitAcceptLanguage($httpAcceptLanguage)
142
149
*/
143
150
protected function getLanguage ($ locale )
144
151
{
145
- return strtolower ( substr ($ locale , 0 , 2 ) );
152
+ return substr ($ locale , 0 , 2 );
146
153
}
147
154
148
155
/**
@@ -160,7 +167,7 @@ protected function getCountry($locale)
160
167
return '' ;
161
168
}
162
169
163
- return strtoupper ( substr ($ locale , $ divider + 1 , 2 ) );
170
+ return substr ($ locale , $ divider + 1 , 2 );
164
171
}
165
172
166
173
/**
@@ -210,10 +217,9 @@ protected function sortLocales()
210
217
*/
211
218
protected function filterLocaleInfo ($ property )
212
219
{
213
- $ filters = ['full ' , 'language ' , 'country ' , 'weight ' ];
214
220
$ locales = $ this ->locales ;
215
221
216
- if ( ! in_array ($ property , $ filters )) {
222
+ if ( ! in_array ($ property , $ this -> filters )) {
217
223
return $ locales ;
218
224
}
219
225
0 commit comments