OrderBy   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A apply() 0 3 1
A __construct() 0 4 1
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
}