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

LangInstall::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1.0787

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 6
c 4
b 0
f 0
dl 0
loc 10
ccs 4
cts 7
cp 0.5714
rs 10
cc 1
nc 1
nop 0
crap 1.0787
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Console;
4
5
use Helldar\LaravelLangPublisher\Facades\Locale;
6
7
final class LangInstall extends BaseCommand
8
{
9
    protected $signature = 'lang:install'
10
    . ' {locales* : Comma-separated list of, eg: de,tk,it}'
11
    . ' {--f|force : Override exiting files}';
12
    . ' {--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 12 at column 4
Loading history...
13
14
    protected $description = 'Install new localizations.';
15 6
16
    public function handle()
17 6
    {
18 6
        $this->install(
19 6
            $this->locales(),
20
            $this->force(),
21
            $this->json()
22
        );
23
24
        $this->result
25
            ->setMessage('Files were not copied.')
26
            ->show();
27 6
    }
28
29 6
    protected function install(array $locales, bool $force = false, bool $json = false): void
30
    {
31 6
        $locales === ['*']
32
            ? $this->installSome(Locale::available(), $force, $json)
33
            : $this->installSome($locales, $force, $json);
34 6
    }
35
36 6
    protected function installSome(array $locales, bool $force = false, bool $json = false): void
37 6
    {
38 6
        foreach ($locales as $locale) {
39
            $this->result->merge(
40
                $this->localization->publish($locale, $force, $json)
41
            );
42
        }
43
    }
44
}
45