Completed
Push — master ( 5c46bf...f77784 )
by Mahmoud
03:22
created

ThisEqualThatCriteria::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace App\Port\Criteria\Eloquent;
4
5
use App\Port\Criteria\Abstracts\Criteria;
6
use Prettus\Repository\Contracts\RepositoryInterface as PrettusRepositoryInterface;
7
8
/**
9
 * Class ThisEqualThatCriteria
10
 *
11
 * @author  Mahmoud Zalt  <[email protected]>
12
 */
13
class ThisEqualThatCriteria extends Criteria
14
{
15
16
    /**
17
     * @var
18
     */
19
    private $field;
20
21
    /**
22
     * @var
23
     */
24
    private $value;
25
26
    /**
27
     * ThisEqualThatCriteria constructor.
28
     *
29
     * @param $field
30
     * @param $value
31
     */
32
    public function __construct($field, $value)
33
    {
34
        $this->field = $field;
35
        $this->value = $value;
36
    }
37
38
    /**
39
     * @param                                                   $model
40
     * @param \Prettus\Repository\Contracts\RepositoryInterface $repository
41
     *
42
     * @return  mixed
43
     */
44
    public function apply($model, PrettusRepositoryInterface $repository)
45
    {
46
        return $model->where($this->field, $this->value);
47
    }
48
}
49