Passed
Pull Request — main (#123)
by Andrey
29:01 queued 13:53
created

Remove   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 30
rs 10
c 2
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A push() 0 4 2
A handle() 0 7 2
A prepareLocales() 0 5 1
A finish() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Helldar\LaravelLangPublisher\Processors;
6
7
use Helldar\Contracts\LangPublisher\Provider;
8
use Helldar\LaravelLangPublisher\Facades\Helpers\Locales;
9
use Helldar\LaravelLangPublisher\Facades\Support\Filesystem;
10
use Helldar\Support\Facades\Helpers\Arr;
11
12
class Remove extends BaseProcessor
13
{
14
    protected $paths = [];
15
16
    public function handle(Provider $provider): void
17
    {
18
        foreach ($this->locales as $locale) {
19
            $json = $this->resourcesPath($locale . '.json');
20
            $php  = $this->resourcesPath($locale);
21
22
            $this->push($json, $php);
23
        }
24
    }
25
26
    public function finish(): void
27
    {
28
        Filesystem::delete($this->paths);
29
    }
30
31
    protected function prepareLocales(array $locales): array
32
    {
33
        $except = Locales::protects();
34
35
        return Arr::except($locales, $except);
36
    }
37
38
    protected function push(string ...$paths): void
39
    {
40
        foreach ($paths as $path) {
41
            array_push($this->paths, $path);
42
        }
43
    }
44
}
45