Passed
Pull Request — master (#57)
by Andrey
13:11
created

LangUninstall::delete()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 3
c 4
b 0
f 0
dl 0
loc 5
ccs 0
cts 4
cp 0
rs 10
cc 2
nc 2
nop 1
crap 6
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Console;
4
5
use Helldar\LaravelLangPublisher\Facades\Locale;
6
7
final class LangUninstall extends BaseCommand
8
{
9
    protected $signature = 'lang:uninstall'
10
    . ' {locales* : Comma-separated list of, eg: de,tk,it}';
11
    . ' {--j|json : Install JSON files}';
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected '.', expecting T_FUNCTION or T_CONST on line 11 at column 4
Loading history...
12
13
    protected $description = 'Uninstall localizations.';
14
15
    public function handle()
16
    {
17
        $this->delete(
18
            $this->locales(),
19
            $this->json()
20
        );
21
22
        $this->result
23
            ->setMessage('No uninstalled localizations.')
24
            ->show();
25
    }
26
27
    protected function delete(array $locales, bool $json = false): void
28
    {
29
        $locales === ['*']
30
            ? $this->deleteSome(Locale::installed(), $json)
31
            : $this->deleteSome($locales, $json);
32
    }
33
34
    protected function deleteSome(array $locales, bool $json = false): void
35
    {
36
        foreach ($locales as $locale) {
37
            $this->result->merge(
38
                $this->localization->delete($locale, $json)
39
            );
40
        }
41
    }
42
}
43