GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( f54b59...2b88e7 )
by Rik
05:03 queued 02:46
created

Having   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 25 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
lcom 1
cbo 2
dl 12
loc 48
c 1
b 0
f 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A modify() 0 9 1
A isSatisfiedBy() 0 4 1
A setType() 12 12 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 Rb\Specification\Doctrine\Query;
4
5
use Doctrine\ORM\QueryBuilder;
6
use Rb\Specification\Doctrine\Exception\InvalidArgumentException;
7
use Rb\Specification\Doctrine\SpecificationInterface;
8
9
10
/**
11
 * @author  Kyle Tucker <[email protected]>
12
 */
13
class Having implements SpecificationInterface
14
{
15
    const HAVING     = 'having';
16
    const AND_HAVING = 'andHaving';
17
    const OR_HAVING  = 'orHaving';
18
19
    protected static $types = [self::HAVING, self::AND_HAVING, self::OR_HAVING];
20
21
    /** @var  string */
22
    protected $type;
23
24
    /** @var  SpecificationInterface */
25
    protected $specification;
26
27
    public function __construct(SpecificationInterface $specification, $type = self::AND_HAVING)
28
    {
29
        $this->specification = $specification;
30
        $this->setType($type);
31
    }
32
33
    public function modify(QueryBuilder $queryBuilder, $dqlAlias)
34
    {
35
        call_user_func_array(
36
            [$queryBuilder, $this->type],
37
            [
38
                $this->specification->modify($queryBuilder, $dqlAlias),
39
            ]
40
        );
41
    }
42
43
    public function isSatisfiedBy($value)
44
    {
45
        return true;
46
    }
47
48 View Code Duplication
    public function setType($type)
0 ignored issues
show
Duplication introduced by
This method 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...
49
    {
50
        if (!in_array($type, self::$types)) {
51
            throw new InvalidArgumentException(sprintf(
52
                '"%s" is not a valid type! Valid types: %s',
53
                $type,
54
                implode(', ', self::$types)
55
            ));
56
        }
57
58
        $this->type = $type;
59
    }
60
}
61