FieldSort   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 2
c 0
b 0
f 0
dl 0
loc 8
ccs 2
cts 2
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A apply() 0 3 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Zing\QueryBuilder\Sorts;
6
7
use Illuminate\Database\Eloquent\Builder;
8
use Zing\QueryBuilder\Contracts\Sort;
9
10
class FieldSort implements Sort
11
{
12
    /**
13
     * @param \Closure|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Database\Query\Expression|string $property
14
     */
15 6
    public function apply(Builder $query, bool $descending, $property): Builder
16
    {
17 6
        return $query->orderBy($property, $descending ? 'desc' : 'asc');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $query->orderBy($...nding ? 'desc' : 'asc') could return the type Illuminate\Database\Query\Builder which is incompatible with the type-hinted return Illuminate\Database\Eloquent\Builder. Consider adding an additional type-check to rule them out.
Loading history...
18
    }
19
}
20