Passed
Push — main ( 30b562...f76792 )
by Andrey
02:42 queued 12s
created

Missing   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 73.32%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 14
c 1
b 0
f 0
dl 0
loc 37
ccs 11
cts 15
cp 0.7332
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A missingError() 0 3 1
A isError() 0 10 2
A unnecessaryError() 0 3 1
A handle() 0 7 3
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Console\Helpers;
4
5
use Helldar\LaravelLangPublisher\Support\Missing as MissingSupport;
6
use Illuminate\Console\Command;
7
8
class Missing extends Command
9
{
10
    protected $signature = 'lang:missing';
11
12
    protected $description = 'Helps identify missing localizations for publication.';
13
14
    protected $hidden = true;
15
16 1
    public function handle(MissingSupport $missing)
17
    {
18 1
        if ($this->missingError($missing) || $this->unnecessaryError($missing)) {
19
            return;
20
        }
21
22 1
        $this->info('Congratulations! All localizations are available!');
23 1
    }
24
25 1
    protected function missingError(MissingSupport $missing): bool
26
    {
27 1
        return $this->isError($missing->missing(), 'We found the following localizations unavailable for installation:');
28
    }
29
30 1
    protected function unnecessaryError(MissingSupport $missing): bool
31
    {
32 1
        return $this->isError($missing->unnecessary(), 'We found the following unnecessary localizations:');
33
    }
34
35 1
    protected function isError(array $locales, string $message): bool
36
    {
37 1
        if (! empty($locales)) {
38
            $this->warn($message);
39
            $this->warn(implode(', ', $locales));
40
41
            return true;
42
        }
43
44 1
        return false;
45
    }
46
}
47