Total Complexity | 8 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | abstract class Base |
||
9 | { |
||
10 | protected $localeConfig; |
||
11 | protected $separator; |
||
12 | |||
13 | 61 | public function __construct(LocaleConfig $localeConfig) |
|
14 | { |
||
15 | 61 | $this->localeConfig = $localeConfig; |
|
16 | } |
||
17 | |||
18 | 41 | public function switchLocale($locale, $string) |
|
19 | { |
||
20 | 41 | $unlocalized = $this->removeLocale($string); |
|
21 | 41 | $localized = $this->addLocale($locale, $unlocalized); |
|
22 | |||
23 | 41 | return $localized; |
|
24 | } |
||
25 | |||
26 | 45 | public function removeLocale($string) |
|
32 | } |
||
33 | |||
34 | 48 | public function prefix($string) |
|
35 | { |
||
36 | 48 | foreach ($this->localeConfig->locales() as $locale) { |
|
37 | 48 | $prefix = $locale . $this->separator; |
|
38 | |||
39 | 48 | if (Str::startsWith($string, $prefix)) { |
|
40 | 7 | return $prefix; |
|
41 | } |
||
42 | } |
||
43 | |||
44 | 43 | return ''; |
|
45 | } |
||
46 | |||
47 | 44 | public function addLocale($locale, $string) |
|
50 | } |
||
51 | |||
52 | 1 | public function locale($string) |
|
55 | } |
||
56 | } |
||
57 |