Passed
Push — master ( d8cc68...c5f99b )
by Andrey
21:06 queued 05:59
created

ResetJson::excluded()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Services\Processors;
4
5
use Helldar\LaravelLangPublisher\Facades\Config;
6
use Helldar\LaravelLangPublisher\Facades\File;
7
use Helldar\LaravelLangPublisher\Traits\Processors\Publishable;
8
use SplFileInfo;
9
10
final class ResetJson extends BaseProcessor
11
{
12
    use Publishable;
13
14
    protected $extension = 'json';
15
16
    protected function publish(): void
17
    {
18
        $this->resetFile(
19
            new SplFileInfo($this->sourcePath())
20
        );
21
    }
22
23
    protected function excluded(array $array, string $filename): array
24
    {
25
        $key  = File::name($filename);
26
        $keys = Config::getExclude($key, [], true);
27
28
        return array_filter($array, static function ($value) use ($keys) {
29
            return in_array($value, $keys);
30
        }, ARRAY_FILTER_USE_KEY);
31
    }
32
}
33