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

Remove   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 14
c 1
b 0
f 0
dl 0
loc 39
rs 10
ccs 6
cts 6
cp 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A targetLocales() 0 3 1
A removeDirectory() 0 5 1
A handle() 0 5 2
A removeJson() 0 5 1
A getAllLocales() 0 3 1
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