Latest::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
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 Latest implements Criterion
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $column;
14
15
    /**
16
     * Latest constructor.
17
     *
18
     * @param string $column
19
     */
20
    public function __construct(string $column = 'id')
21
    {
22
        $this->column = $column;
23
    }
24
25
    /**
26
     * @param Builder|mixed $model
27
     *
28
     * @return Builder|mixed
29
     */
30
    public function apply($model)
31
    {
32
        return $model->orderByDesc($this->column);
33
    }
34
}
35