FiltersTrashed::__invoke()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
cc 3
nc 3
nop 3
1
<?php
2
3
namespace Spatie\QueryBuilder\Filters;
4
5
use Illuminate\Database\Eloquent\Builder;
6
7
class FiltersTrashed implements Filter
8
{
9
    /** {@inheritdoc} */
10
    public function __invoke(Builder $query, $value, string $property)
11
    {
12
        if ($value === 'with') {
13
            $query->withTrashed();
14
15
            return;
16
        }
17
18
        if ($value === 'only') {
19
            $query->onlyTrashed();
20
21
            return;
22
        }
23
24
        $query->withoutTrashed();
25
    }
26
}
27