Passed
Push — master ( d8cc68...c5f99b )
by Andrey
21:06 queued 05:59
created

Deletable::delete()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 9
ccs 0
cts 0
cp 0
rs 10
cc 3
nc 3
nop 0
crap 12
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Traits\Processors;
4
5
use Helldar\LaravelLangPublisher\Constants\Status;
6
use Illuminate\Support\Facades\File as IlluminateFile;
7
8
trait Deletable
9 24
{
10
    public function run(): array
11
    {
12
        $this->delete()
13 24
            ? $this->push('*', Status::DELETED)
0 ignored issues
show
Bug introduced by
It seems like push() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

13
            ? $this->/** @scrutinizer ignore-call */ push('*', Status::DELETED)
Loading history...
14 12
            : $this->push('*', Status::SKIPPED);
15 12
16
        return $this->result();
0 ignored issues
show
Bug introduced by
It seems like result() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

16
        return $this->/** @scrutinizer ignore-call */ result();
Loading history...
17 24
    }
18
19
    protected function delete(): bool
20
    {
21
        if ($this->isProtected()) {
0 ignored issues
show
Bug introduced by
It seems like isProtected() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
        if ($this->/** @scrutinizer ignore-call */ isProtected()) {
Loading history...
22
            return false;
23
        }
24
25
        return $this->wantsJson()
0 ignored issues
show
Bug introduced by
It seems like wantsJson() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
        return $this->/** @scrutinizer ignore-call */ wantsJson()
Loading history...
26
            ? IlluminateFile::delete($this->targetPath())
0 ignored issues
show
Bug introduced by
It seems like targetPath() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
            ? IlluminateFile::delete($this->/** @scrutinizer ignore-call */ targetPath())
Loading history...
27
            : IlluminateFile::deleteDirectory($this->targetPath());
28
    }
29
}
30