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

OrderBy::apply()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
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