Total Complexity | 5 |
Total Lines | 53 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | class CombinedFilter implements Filter |
||
8 | { |
||
9 | /** |
||
10 | * The filtered results. |
||
11 | * |
||
12 | * @var array |
||
13 | */ |
||
14 | protected $filtered; |
||
15 | |||
16 | /** |
||
17 | * Filter the locales. |
||
18 | * |
||
19 | * @param array $locales |
||
20 | * |
||
21 | * @return array |
||
22 | */ |
||
23 | 2 | public function filter(array $locales) |
|
24 | { |
||
25 | 2 | $this->filtered = []; |
|
26 | |||
27 | 2 | foreach ($locales as $locale) { |
|
28 | 1 | $this->filterLocale($locale); |
|
29 | } |
||
30 | |||
31 | 2 | return $this->filtered; |
|
32 | } |
||
33 | |||
34 | /** |
||
35 | * Filter the given Locale. |
||
36 | * |
||
37 | * @param \CodeZero\BrowserLocale\Locale $locale |
||
38 | * |
||
39 | * @return void |
||
40 | */ |
||
41 | 1 | protected function filterLocale(Locale $locale) |
|
42 | { |
||
43 | 1 | $language = substr($locale->locale, 0, 2); |
|
44 | |||
45 | 1 | $this->addLocale($locale->locale); |
|
46 | 1 | $this->addLocale($language); |
|
47 | 1 | } |
|
48 | |||
49 | /** |
||
50 | * Add a locale to the results array. |
||
51 | * |
||
52 | * @param string $locale |
||
53 | * |
||
54 | * @return void |
||
55 | */ |
||
56 | 1 | protected function addLocale($locale) |
|
60 | } |
||
61 | 1 | } |
|
62 | } |
||
63 |