Passed
Push — 10.x ( 912076...7ef113 )
by Andrey
12:30
created

Remove::removeJson()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 5
rs 10
ccs 0
cts 0
cp 0
cc 1
nc 1
nop 1
crap 2
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 4
declare(strict_types=1);
19
20 4
namespace Helldar\LaravelLangPublisher\Console;
21
22 4
use Helldar\LaravelLangPublisher\Facades\Helpers\Locales;
23 4
use Helldar\Support\Facades\Helpers\Filesystem\Directory;
24
use Helldar\Support\Facades\Helpers\Filesystem\File;
25 4
26
class Remove extends Base
27 4
{
28
    protected $signature = 'lang:rm'
29 4
    . ' {locales?* : Space-separated list of, eg: de tk it}';
30
31 4
    protected $description = 'Remove localizations.';
32
33 4
    protected $method = 'remove';
34
35 4
    public function handle()
36
    {
37 4
        foreach ($this->targetLocales() as $locale) {
38
            $this->removeDirectory($locale);
39
            $this->removeJson($locale);
40
        }
41
    }
42
43
    protected function removeDirectory(string $locale): void
44
    {
45
        $path = $this->resourcesPath($locale);
46
47
        Directory::ensureDelete($path);
48
    }
49
50
    protected function removeJson(string $locale): void
51
    {
52
        $path = $this->resourcesPath($locale . '.json');
53
54
        File::ensureDelete($path);
55
    }
56
57
    protected function targetLocales(): array
58
    {
59
        return $this->askLocales($this->method);
60
    }
61
62
    protected function getAllLocales(): array
63
    {
64
        return Locales::installed();
65
    }
66
}
67