OrderBy::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace OkayBueno\Repositories\Criteria\Eloquent;
4
5
use OkayBueno\Repositories\Criteria\CriteriaInterface;
6
7
/**
8
 * Class OrderBy
9
 * @package OkayBueno\Repositories\Criteria\src
10
 */
11
class OrderBy implements CriteriaInterface
12
{
13
    protected $orderBy;
14
    protected $direction;
15
16
17
    /**
18
     * @param $orderBy
19
     * @param string $direction
20
     */
21
    public function __construct( $orderBy, $direction = 'ASC' )
22
    {
23
        $this->orderBy = $orderBy;
24
        $this->direction = $direction;
25
    }
26
27
28
    /**
29
     * @param mixed $queryBuilder
30
     * @return mixed
31
     */
32
    public function apply( $queryBuilder )
33
    {
34
        return $queryBuilder->orderBy( $this->orderBy, $this->direction );
35
    }
36
37
38
}