Passed
Push — main ( 30b562...f76792 )
by Andrey
02:42 queued 12s
created

Missing::unnecessary()   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 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Support;
4
5
use DirectoryIterator;
6
use Helldar\LaravelLangPublisher\Facades\File as FileFacade;
7
use Helldar\LaravelLangPublisher\Facades\Locale as LocaleSupport;
8
use Illuminate\Support\Facades\Config as IlluminateConfig;
9
10
class Missing
11
{
12 2
    public function missing(): array
13
    {
14 2
        return array_diff($this->sourceAvailable(), $this->mainAvailable());
15
    }
16
17 1
    public function unnecessary(): array
18
    {
19 1
        return array_diff($this->mainAvailable(), $this->sourceAvailable());
20
    }
21
22 2
    protected function mainAvailable(): array
23
    {
24 2
        return LocaleSupport::availableAll();
25
    }
26
27 2
    protected function sourceAvailable(): array
28
    {
29 2
        $names = ['en'];
30
31 2
        foreach ($this->directories() as $file) {
32 2
            if (! $file->isDot() && $file->isDir()) {
33 2
                $names[] = $file->getFilename();
34
            }
35
        }
36
37 2
        return array_values(array_unique($names));
38
    }
39
40 2
    protected function sourcePath(): string
41
    {
42 2
        $path = IlluminateConfig::get(Config::KEY_PRIVATE . '.vendor');
43
44 2
        return rtrim($path, '/') . '/src';
45
    }
46
47
    /**
48
     * @return \DirectoryIterator|\DirectoryIterator[]
49
     */
50 2
    protected function directories(): DirectoryIterator
51
    {
52 2
        return FileFacade::files($this->sourcePath());
53
    }
54
}
55