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 Orkhanahmadov\EloquentRepository\Repository\Eloquent\Criteria;
4
5
use Illuminate\Database\Eloquent\Builder;
6
use Orkhanahmadov\EloquentRepository\Repository\Criteria\Criterion;
7
8
class OrderBy implements Criterion
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $column;
14
    /**
15
     * @var string
16
     */
17
    protected $sortBy;
18
19
    /**
20
     * OrderBy constructor.
21
     *
22
     * @param string $column
23
     * @param string $sortBy
24
     */
25
    public function __construct(string $column, string $sortBy)
26
    {
27
        $this->column = $column;
28
        $this->sortBy = $sortBy;
29
    }
30
31
    /**
32
     * @param Builder|mixed $model
33
     *
34
     * @return Builder|mixed
35
     */
36
    public function apply($model)
37
    {
38
        return $model->orderBy($this->column, $this->sortBy);
39
    }
40
}
41