Passed
Pull Request — master (#185)
by
unknown
02:16
created

QueryScope::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
rs 10
1
<?php
2
3
/**
4
 * Cycle DataMapper ORM
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Cycle\ORM\Select\Scope;
13
14
use Cycle\ORM\Select\QueryBuilder;
15
use Cycle\ORM\Select\ScopeInterface;
16
17
/**
18
 * Provides the ability to scope query and load necessary relations into the loader.
19
 * @final
20
 */
21
class QueryScope implements ScopeInterface
22
{
23
    /** @var array */
24
    private $where;
25
26
    /** @var array */
27
    private $orderBy;
28
29
    /**
30
     * @param array $where
31
     * @param array $orderBy
32
     */
33
    public function __construct(array $where, array $orderBy = [])
34
    {
35
        $this->where = $where;
36
        $this->orderBy = $orderBy;
37
    }
38
39
    /**
40
     * @inheritdoc
41
     */
42
    public function apply(QueryBuilder $query): void
43
    {
44
        $query->where($this->where)->orderBy($this->orderBy);
45
    }
46
}
47