Passed
Push — main ( 843490...c1da4d )
by Mohammad
07:53
created

SoftDeletesRepository::withTrash()   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
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
use Illuminate\Database\Eloquent\Builder;
4
5
trait SoftDeletesRepository
6
{
7
    /**
8
     * @param int $id
9
     *
10
     * @return bool
11
     */
12
    public function restore(int $id): bool
13
    {
14
        return $this->getNewBuilderWithScope()->where('id', $id)->restore();
0 ignored issues
show
Bug introduced by
It seems like getNewBuilderWithScope() 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

14
        return $this->/** @scrutinizer ignore-call */ getNewBuilderWithScope()->where('id', $id)->restore();
Loading history...
15
    }
16
17
    /**
18
     * @param int $id
19
     *
20
     * @return bool
21
     */
22
    public function forceDelete(int $id): bool
23
    {
24
        return $this->getNewBuilderWithScope()->where('id', $id)->forceDelete();
25
    }
26
27
    public function onlyTrash(): self
28
    {
29
        $this->scope(fn (Builder $builder) => $builder->onlyTrash());
0 ignored issues
show
Bug introduced by
It seems like scope() 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

29
        $this->/** @scrutinizer ignore-call */ 
30
               scope(fn (Builder $builder) => $builder->onlyTrash());
Loading history...
30
31
        return $this;
32
    }
33
34
    public function withTrash(): self
35
    {
36
        $this->scope(fn (Builder $builder) => $builder->withTrash());
37
38
        return $this;
39
    }
40
}
41