Passed
Pull Request — master (#60)
by Andrey
11:17
created

PublishJson   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
c 1
b 0
f 0
dl 0
loc 20
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A excluded() 0 7 1
A publish() 0 4 1
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Services\Processors;
4
5
use Helldar\LaravelLangPublisher\Facades\Config;
6
use Helldar\LaravelLangPublisher\Traits\Processors\Publishable;
7
use SplFileInfo;
8
9
final class PublishJson extends BaseProcessor
10
{
11
    use Publishable;
12
13
    protected $extension = 'json';
14
15
    protected function publish(): void
16
    {
17
        $this->publishFile(
18
            new SplFileInfo($this->sourcePath())
19
        );
20
    }
21
22
    protected function excluded(array $array, string $key): array
23
    {
24
        $keys = Config::getExclude($key, [], true);
25
26
        return array_filter($array, static function ($value) use ($keys) {
27
            return in_array($value, $keys);
28
        }, ARRAY_FILTER_USE_KEY);
29
    }
30
}
31