Passed
Push — main ( f4d82a...ca2db5 )
by Andrey
03:23 queued 12s
created

Remove::push()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the "andrey-helldar/laravel-lang-publisher" project.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * @author Andrey Helldar <[email protected]>
10
 *
11
 * @copyright 2021 Andrey Helldar
12
 *
13
 * @license MIT
14
 *
15
 * @see https://github.com/andrey-helldar/laravel-lang-publisher
16
 */
17
18
declare(strict_types=1);
19
20
namespace Helldar\LaravelLangPublisher\Processors;
21
22
use Helldar\Contracts\LangPublisher\Provider;
23
use Helldar\LaravelLangPublisher\Facades\Helpers\Locales;
24
use Helldar\LaravelLangPublisher\Facades\Support\Filesystem;
25
26
class Remove extends BaseProcessor
27
{
28
    protected $paths = [];
29
30 8
    public function handle(Provider $provider): void
31
    {
32 8
        foreach ($this->locales as $locale) {
33 4
            $json = $this->resourcesPath($locale . '.json');
34 4
            $php  = $this->resourcesPath($locale);
35
36 4
            $this->push($json, $php);
37
        }
38 8
    }
39
40 8
    public function finish(): void
41
    {
42 8
        Filesystem::delete($this->paths);
43 8
    }
44
45 8
    protected function prepareLocales(array $locales): array
46
    {
47 8
        $except = Locales::protects();
48
49 8
        return array_diff($locales, $except);
50
    }
51
52 4
    protected function push(string ...$paths): void
53
    {
54 4
        foreach ($paths as $path) {
55 4
            array_push($this->paths, $path);
56
        }
57 4
    }
58
}
59