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

QueryMutator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 34
ccs 0
cts 13
cp 0
rs 10

3 Methods

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