Local::setLocal()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 10
ccs 4
cts 5
cp 0.8
crap 2.032
rs 9.9332
c 0
b 0
f 0
1
<?php
2
namespace agoalofalife\Support;
3
4
use agoalofalife\Contracts\LocalizationContract;
5
use Mockery\Exception;
6
7
class Local implements LocalizationContract
8
{
9
    protected $mapLocal = [
10
        'ru' => 0,
11
        'ua' => 1,
12
        'be' => 2,
13
        'en' => 3,
14
        'es' => 4,
15
        'fi' => 5,
16
        'de' => 6,
17
        'it' => 7
18
    ];
19
20 1
    public function setLocal(string $local)
21
    {
22 1
        if ( isset($this->mapLocal[$local]) )
23
        {
24 1
            config(['geography.locale' => $this->mapLocal[$local]]);
25
        } else{
26
            throw new Exception('not locale');
27
        }
28
29
    }
30
}