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

DeleteJson   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isProtected() 0 3 1
A delete() 0 5 2
A path() 0 3 1
A run() 0 9 2
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Services\Processing;
4
5
use Helldar\LaravelLangPublisher\Constants\Status;
6
use Helldar\LaravelLangPublisher\Facades\Locale;
7
use Helldar\LaravelLangPublisher\Facades\Path;
8
use Illuminate\Support\Facades\File as IlluminateFile;
9
10
final class DeleteJson extends BaseProcess
11
{
12
    protected $extension = 'json';
13
14 12
    public function run(): array
15
    {
16 12
        $this->checkExists($this->path());
17
18 12
        $this->delete()
19 6
            ? $this->push('*', Status::DELETED)
20 6
            : $this->push('*', Status::SKIPPED);
21
22 12
        return $this->result();
23
    }
24
25 12
    protected function delete(): bool
26
    {
27 12
        return ! $this->isProtected()
28 6
            ? IlluminateFile::deleteDirectory($this->path())
29 12
            : false;
30
    }
31
32 12
    protected function path(): string
33
    {
34 12
        return Path::target($this->locale);
35
    }
36
37 12
    protected function isProtected(): bool
38
    {
39 12
        return Locale::isProtected($this->locale);
40
    }
41
}
42