Not::modify()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
/**
4
 * This file is part of the Happyr Doctrine Specification package.
5
 *
6
 * (c) Tobias Nyholm <[email protected]>
7
 *     Kacper Gunia <[email protected]>
8
 *     Peter Gribanov <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Happyr\DoctrineSpecification\Logic;
15
16
use Doctrine\ORM\QueryBuilder;
17
use Happyr\DoctrineSpecification\Filter\Filter;
18
use Happyr\DoctrineSpecification\Query\QueryModifier;
19
use Happyr\DoctrineSpecification\Specification\Specification;
20
21
class Not implements Specification
22
{
23
    /**
24
     * @var Filter child
25
     */
26
    private $child;
27
28
    /**
29
     * @param Filter $expr
30
     */
31
    public function __construct(Filter $expr)
32
    {
33
        $this->child = $expr;
34
    }
35
36
    /**
37
     * @param QueryBuilder $qb
38
     * @param string       $dqlAlias
39
     *
40
     * @return string
41
     */
42
    public function getFilter(QueryBuilder $qb, $dqlAlias)
43
    {
44
        return (string) $qb->expr()->not($this->child->getFilter($qb, $dqlAlias));
45
    }
46
47
    /**
48
     * @param QueryBuilder $query
49
     * @param string       $dqlAlias
50
     */
51
    public function modify(QueryBuilder $query, $dqlAlias)
52
    {
53
        if ($this->child instanceof QueryModifier) {
54
            $this->child->modify($query, $dqlAlias);
55
        }
56
    }
57
}
58