Code Duplication    Length = 37-37 lines in 2 locations

src/Filter/InstanceOfX.php 1 location

@@ 7-43 (lines=37) @@
4
5
use Doctrine\ORM\QueryBuilder;
6
7
class InstanceOfX implements Filter
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 INSTANCE OF %s', $dqlAlias, $this->value);
42
    }
43
}
44

src/Filter/MemberOfX.php 1 location

@@ 7-43 (lines=37) @@
4
5
use Doctrine\ORM\QueryBuilder;
6
7
class MemberOfX implements Filter
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