Completed
Push — master ( f3d932...88ba9b )
by Dmitry
03:14
created

QueryMutator::getQuery()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
4
namespace hiapi\query;
5
6
class QueryMutator
7
{
8
    /**
9
     * @var \yii\db\Query
10
     */
11
    protected $query;
12
13
    /**
14
     * QueryMutator constructor.
15
     * @param \yii\db\Query $query
16
     */
17
    public function __construct($query)
18
    {
19
        $this->query = $query;
20
    }
21
22
    public function apply(Specification $specification)
23
    {
24
        if ($specification->where) {
25
            $this->query->andWhere($specification->where);
26
        }
27
28
        if ($specification->limit) {
29
            $this->query->limit($specification->limit);
30
        }
31
32
        return $this;
33
    }
34
35
    public function getQuery()
36
    {
37
        return $this->query;
38
    }
39
}
40