Completed
Push — master ( 88ba9b...8a3d51 )
by Andrii
03:03
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
use yii\db\Query;
4
5
namespace hiapi\query;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Namespace declaration statement has to be the very first statement in the script
Loading history...
6
7
class QueryMutator
8
{
9
    /**
10
     * @var Query
11
     */
12
    protected $query;
13
14
    /**
15
     * @param 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