Passed
Pull Request — main (#84)
by Andrey
59:33 queued 44:34
created

Uninstall   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 28
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A exists() 0 5 1
A skipped() 0 5 1
A delete() 0 7 1
A run() 0 3 2
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Services\Processors;
4
5
use Helldar\LaravelLangPublisher\Constants\Status;
6
use Helldar\Support\Facades\Helpers\Filesystem\File;
7
8
final class Uninstall extends Processor
9
{
10
    public function run(): string
11
    {
12
        return $this->exists() ? $this->delete() : $this->skipped();
13
    }
14
15
    protected function exists(): bool
16
    {
17
        $this->log('Checking for the existence of a file: ' . $this->target_path);
18
19
        return File::exists($this->target_path);
20
    }
21
22
    protected function delete(): string
23
    {
24
        $this->log('Deleting a file: ' . $this->target_path);
25
26
        File::delete($this->target_path);
27
28
        return Status::DELETED;
29
    }
30
31
    protected function skipped(): string
32
    {
33
        $this->log('Skipping file processing: ' . $this->target_path);
34
35
        return Status::SKIPPED;
36
    }
37
}
38