Passed
Push — master ( 15e0d6...f84924 )
by Anton
06:34
created

OrderByTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 18
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A setOrderBy() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\ORM\Select\Traits;
6
7
use Cycle\ORM\Select\QueryBuilder;
8
use Spiral\Database\Query\SelectQuery;
9
10
/**
11
 * Provides the ability to configure relation specific where conditions.
12
 */
13
trait OrderByTrait
14
{
15
    /**
16
     * @param SelectQuery   $query
17
     * @param string        $table  Table name to be automatically inserted into where conditions at place of {@}.
18
     * @param array         $order  Associative array where the keys are field names
19
     *                              and the values are ASC or DESC strings
20
     * @return SelectQuery
21
     */
22
    private function setOrderBy(SelectQuery $query, string $table, array $order = []): SelectQuery
0 ignored issues
show
Unused Code introduced by
The parameter $table is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

22
    private function setOrderBy(SelectQuery $query, /** @scrutinizer ignore-unused */ string $table, array $order = []): SelectQuery

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
23
    {
24
        if ($order === []) {
25
            return $query;
26
        }
27
28
        $proxy = new QueryBuilder($query, $this);
0 ignored issues
show
Bug introduced by
$this of type Cycle\ORM\Select\Traits\OrderByTrait is incompatible with the type Cycle\ORM\Select\AbstractLoader expected by parameter $loader of Cycle\ORM\Select\QueryBuilder::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

28
        $proxy = new QueryBuilder($query, /** @scrutinizer ignore-type */ $this);
Loading history...
29
30
        return $proxy->orderBy($order)->getQuery();
31
    }
32
}
33