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

Uninstall::exists()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
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