Completed
Push — master ( c35364...d93af0 )
by Peter
09:29
created

MemberOfX::getFilter()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace Happyr\DoctrineSpecification\Filter;
4
5
use Doctrine\ORM\QueryBuilder;
6
7 View Code Duplication
class MemberOfX implements Filter
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    /**
10
     * @var string
11
     */
12
    private $value;
13
14
    /**
15
     * @var string|null
16
     */
17
    private $dqlAlias;
18
19
    /**
20
     * @param string      $value
21
     * @param string|null $dqlAlias
22
     */
23
    public function __construct($value, $dqlAlias = null)
24
    {
25
        $this->dqlAlias = $dqlAlias;
26
        $this->value = $value;
27
    }
28
29
    /**
30
     * @param QueryBuilder $qb
31
     * @param string       $dqlAlias
32
     *
33
     * @return string
34
     */
35
    public function getFilter(QueryBuilder $qb, $dqlAlias)
36
    {
37
        if (null !== $this->dqlAlias) {
38
            $dqlAlias = $this->dqlAlias;
39
        }
40
41
        return sprintf('%s MEMBER OF %s', $dqlAlias, $this->value);
42
    }
43
}
44