Test Failed
Pull Request — master (#170)
by Serhii
13:10
created

FromScope   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A apply() 0 4 1
A __construct() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Matchish\ScoutElasticSearch\Database\Scopes;
5
6
use Illuminate\Database\Eloquent\Builder;
7
use Illuminate\Database\Eloquent\Model;
8
use Illuminate\Database\Eloquent\Scope;
9
10
class FromScope implements Scope
11
{
12
13
    /**
14
     * @var mixed
15
     */
16
    private $from;
17
18
    /**
19
     * @param mixed $from
20
     */
21
    public function __construct($from)
22
    {
23
24
        $this->from = $from;
25
    }
26
27
    /**
28
     * Apply the scope to a given Eloquent query builder.
29
     *
30
     * @param \Illuminate\Database\Eloquent\Builder $builder
31
     * @param \Illuminate\Database\Eloquent\Model $model
32
     * @return void
33
     */
34
    public function apply(Builder $builder, Model $model)
35
    {
36
        $column = $model->getKeyName();
37
        $builder->where($column, '>', $this->from);
38
    }
39
}
40