Completed
Push — master ( ea487b...367ab0 )
by Joachim
05:21
created

IdGreaterThanFilter::filter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\SyliusStockMovementPlugin\Filter;
6
7
use Doctrine\ORM\QueryBuilder;
8
use Safe\Exceptions\StringsException;
9
use function Safe\sprintf;
10
11
final class IdGreaterThanFilter extends Filter
12
{
13
    /** @var int */
14
    private $id;
15
16
    public function __construct(int $id)
17
    {
18
        $this->id = $id;
19
    }
20
21
    /**
22
     * @throws StringsException
23
     */
24
    public function filter(QueryBuilder $queryBuilder): void
25
    {
26
        $alias = $this->getRootAlias($queryBuilder);
27
28
        $queryBuilder->andWhere(sprintf('%s.id > :id', $alias))->setParameter('id', $this->id);
29
    }
30
}
31