Passed
Push — main ( 55f929...127e84 )
by Andrey
161:41 queued 158:10
created

Missing::missing()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Services;
4
5
use Helldar\LaravelLangPublisher\Facades\Arr as ArrFacade;
6
use Helldar\LaravelLangPublisher\Facades\Config;
7
use Helldar\LaravelLangPublisher\Facades\Locales;
8
use Helldar\Support\Facades\Helpers\Arr;
9
use Helldar\Support\Facades\Helpers\Filesystem\Directory;
10
11
final class Missing
12
{
13 1
    public function missing(): array
14
    {
15 1
        return array_diff($this->available(), $this->main());
16
    }
17
18 1
    public function unnecessary(): array
19
    {
20 1
        return array_diff($this->main(), $this->available());
21
    }
22
23 2
    protected function main(): array
24
    {
25 2
        return Locales::available(true);
26
    }
27
28 2
    protected function available(): array
29
    {
30 2
        $locales = ArrFacade::unique(array_merge(['en'], $this->locales()));
31
32 2
        $sorted = Arr::sort($locales);
33
34 2
        return array_values($sorted);
35
    }
36
37 2
    protected function locales(): array
38
    {
39 2
        return Directory::names($this->path());
40
    }
41
42 2
    protected function path(): string
43
    {
44 2
        return Config::localesPath();
45
    }
46
}
47