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

Remove::finish()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
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