Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
FromFileLanguage | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |
0.00% |
0 / 1 |
fromContext | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 |
1 | <?php |
2 | namespace Apie\Core\Translator\Enums; |
3 | |
4 | use Apie\Core\Context\ApieContext; |
5 | |
6 | enum FromFileLanguage: string |
7 | { |
8 | case EN = 'en'; |
9 | case NL = 'nl'; |
10 | |
11 | public static function fromContext(ApieContext $apieContext): self |
12 | { |
13 | $locale = $apieContext->getContext('locale', false) ?? 'en'; |
14 | if (strpos($locale, '_')) { |
15 | $locale = substr($locale, strpos($locale, '_')); |
16 | } |
17 | return FromFileLanguage::tryFrom($locale) ?? self::EN; |
18 | } |
19 | } |