Issues (22)

src/Sorts/FieldSort.php (1 issue)

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