Test Setup Failed
Push — master ( ef125c...60f940 )
by he
08:55
created

OrderBy   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A apply() 0 3 1
1
<?php
2
3
namespace App\Repositories\Criteria;
4
5
use Czim\Repository\Contracts\BaseRepositoryInterface;
6
use Czim\Repository\Contracts\CriteriaInterface;
7
8
class OrderBy implements CriteriaInterface
9
{
10
    private $field;
11
    private $order;
12
13
    /**
14
     * OrderBy constructor.
15
     *
16
     * @param $field
17
     * @param $order
18
     */
19
    public function __construct($field, $order = 'asc')
20
    {
21
        $this->field = $field;
22
        $this->order = $order;
23
    }
24
25
    public function apply($model, BaseRepositoryInterface $repository)
26
    {
27
        return $model->orderBy($this->field, $this->order);
28
    }
29
}
30