OrderByCriteria   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A apply() 0 4 2
1
<?php
2
3
namespace Anavel\Crud\Repository\Criteria;
4
5
use ANavallaSuiza\Laravel\Database\Contracts\Repository\Criteria;
6
use ANavallaSuiza\Laravel\Database\Contracts\Repository\Repository;
7
8
class OrderByCriteria implements Criteria
9
{
10
    protected $byColumn;
11
    protected $reverse;
12
13
    public function __construct($byColumn, $reverse = false)
14
    {
15
        $this->byColumn = $byColumn;
16
        $this->reverse = $reverse;
17
    }
18
19
    public function apply($model, Repository $repository)
20
    {
21
        return $model->orderBy($this->byColumn, ($this->reverse ? 'DESC' : 'ASC'));
22
    }
23
}
24