Passed
Push — master ( 9c833b...4586fd )
by Zing
09:40 queued 04:04
created

FieldSort::apply()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 1
nop 3
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 2
rs 10
c 0
b 0
f 0
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 3
    public function apply(Builder $query, bool $descending, string $property): Builder
13
    {
14 3
        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...
15
    }
16
}
17