Passed
Push — main ( 5713ab...156ba4 )
by Andrey
55:20 queued 52:20
created

Missing::get()   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
eloc 1
c 1
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 get(): array
13
    {
14 2
        return array_diff($this->sourceAvailable(), $this->mainAvailable());
15
    }
16
17 2
    protected function mainAvailable(): array
18
    {
19 2
        return LocaleSupport::availableAll();
20
    }
21
22 2
    protected function sourceAvailable(): array
23
    {
24 2
        $names = ['en'];
25
26 2
        foreach ($this->directories() as $file) {
27 2
            if (! $file->isDot() && $file->isDir()) {
28 2
                $names[] = $file->getFilename();
29
            }
30
        }
31
32 2
        return array_values(array_unique($names));
33
    }
34
35 2
    protected function sourcePath(): string
36
    {
37 2
        $path = IlluminateConfig::get(Config::KEY_PRIVATE . '.vendor');
38
39 2
        return rtrim($path, '/') . '/src';
40
    }
41
42
    /**
43
     * @return \DirectoryIterator|\DirectoryIterator[]
44
     */
45 2
    protected function directories(): DirectoryIterator
46
    {
47 2
        return FileFacade::files($this->sourcePath());
48
    }
49
}
50