Latest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A apply() 0 3 1
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