SoftDeletesRepository   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A withTrash() 0 5 1
A restore() 0 3 1
A onlyTrash() 0 5 1
A forceDelete() 0 3 1
1
<?php
2
3
use Illuminate\Database\Eloquent\Builder;
4
5
trait SoftDeletesRepository
6
{
7
    public function restore(int $id): bool
8
    {
9
        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

9
        return $this->/** @scrutinizer ignore-call */ getNewBuilderWithScope()->where('id', $id)->restore();
Loading history...
10
    }
11
12
    public function forceDelete(int $id): bool
13
    {
14
        return $this->getNewBuilderWithScope()->where('id', $id)->forceDelete();
15
    }
16
17
    public function onlyTrash(): self
18
    {
19
        $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

19
        $this->/** @scrutinizer ignore-call */ 
20
               scope(fn (Builder $builder) => $builder->onlyTrash());
Loading history...
20
21
        return $this;
22
    }
23
24
    public function withTrash(): self
25
    {
26
        $this->scope(fn (Builder $builder) => $builder->withTrash());
27
28
        return $this;
29
    }
30
}
31