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

MemberOfX   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 37
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A getFilter() 8 8 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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