Passed
Pull Request — master (#65)
by Andrey
17:57 queued 02:52
created

Localization   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 5
eloc 20
dl 0
loc 54
ccs 11
cts 11
cp 1
rs 10
c 4
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 7 1
A setPath() 0 5 1
A setProcessor() 0 5 1
A full() 0 5 1
A force() 0 5 1
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Services;
4
5
use Helldar\LaravelLangPublisher\Contracts\Localizationable;
6
use Helldar\LaravelLangPublisher\Contracts\Pathable;
7
use Helldar\LaravelLangPublisher\Contracts\Processor;
8
use Helldar\LaravelLangPublisher\Traits\Containable;
9
10
final class Localization implements Localizationable
11
{
12
    use Containable;
13
14
    /** @var \Helldar\LaravelLangPublisher\Contracts\Pathable */
15
    protected $path;
16
17
    /** @var \Helldar\LaravelLangPublisher\Contracts\Processor */
18
    protected $processor;
19
20
    /** @var array */
21
    protected $result = [];
22
23 78
    /** @var bool */
24
    protected $is_force = false;
25 78
26
    /** @var bool */
27 78
    protected $is_full = false;
28
29
    public function setPath(Pathable $path): Localizationable
30 78
    {
31
        $this->path = $path;
32 78
33
        return $this;
34 78
    }
35
36
    public function setProcessor(Processor $processor): Localizationable
37 78
    {
38
        $this->processor = $processor;
39 78
40 78
        return $this;
41 78
    }
42 78
43
    public function force(bool $is_force = true): Localizationable
44
    {
45
        $this->is_force = $is_force;
46
47
        return $this;
48
    }
49
50
    public function full(bool $is_full = true): Localizationable
51
    {
52
        $this->is_full = $is_full;
53
54
        return $this;
55
    }
56
57
    public function run(string $locale): array
58
    {
59
        return $this->processor
60
            ->locale($locale)
61
            ->force($this->is_force)
62
            ->full($this->is_full)
63
            ->run();
64
    }
65
}
66