Passed
Push — master ( c97482...68f9e3 )
by Andrey
07:00 queued 04:30
created

LangInstall::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1.0527

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 7
c 4
b 0
f 0
dl 0
loc 11
ccs 5
cts 8
cp 0.625
rs 10
cc 1
nc 1
nop 0
crap 1.0527
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* : Space-separated list of, eg: de tk it}'
11
    . ' {--f|force : Override exiting files}'
12
    . ' {--j|json : Install JSON files}';
13
14
    protected $description = 'Install new localizations.';
15
16 12
    public function handle()
17
    {
18 12
        $this->install(
19 12
            $this->locales(),
20 12
            $this->isForce(),
21 12
            $this->isJson()
22
        );
23
24
        $this->result
25
            ->setMessage('Files were not copied.')
26
            ->show();
27
    }
28
29 12
    protected function install(array $locales, bool $force = false, bool $json = false): void
30
    {
31 12
        $locales === ['*']
32
            ? $this->installSome(Locale::available(), $force, $json)
33 12
            : $this->installSome($locales, $force, $json);
34
    }
35
36 12
    protected function installSome(array $locales, bool $force = false, bool $json = false): void
37
    {
38 12
        foreach ($locales as $locale) {
39 12
            $this->result->merge(
40 12
                $this->localization->publish($locale, $force, $json)
41
            );
42
        }
43
    }
44
}
45