Passed
Pull Request — 3.x (#201)
by Giso
02:58
created

ObjectIdCondition::apply()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
4
namespace DH\DoctrineAuditBundle\Reader;
5
6
7
use Doctrine\DBAL\Connection;
8
use Doctrine\DBAL\Query\QueryBuilder;
9
10
class ObjectIdCondition implements ConditionInterface
11
{
12
    /**
13
     * @var null|int|string
14
     */
15
    private $id;
16
17
    /**
18
     * Apply object id filtering
19
     *
20
     * @param null|int|string $id
21
     */
22
    public function __construct($id = null)
23
    {
24
        $this->id = $id;
25
    }
26
27
    public function apply(QueryBuilder $queryBuilder)
28
    {
29
        if (null !== $this->id) {
30
            $queryBuilder
31
                ->andWhere('object_id = :object_id')
32
                ->setParameter('object_id', $this->id)
33
            ;
34
        }
35
    }
36
}
37