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 ( 67de0b...f54b59 )
by Rik
03:01
created

Select::setType()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 12
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 12
loc 12
rs 9.4285
cc 2
eloc 7
nc 2
nop 1
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
 * Select will modify the query-builder so you can specify SELECT-statements.
11
 */
12
class Select implements SpecificationInterface
13
{
14
    const SELECT     = 'select';
15
    const ADD_SELECT = 'addSelect';
16
17
    protected static $types = [self::SELECT, self::ADD_SELECT];
18
19
    /**
20
     * @var string|array
21
     */
22
    protected $select;
23
24
    /**
25
     * @var string
26
     */
27
    protected $type;
28
29
    /**
30
     * @param string|array $select
31
     * @param string       $type
32
     */
33
    public function __construct($select, $type = self::ADD_SELECT)
34
    {
35
        $this->setType($type);
36
        $this->select = $select;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function modify(QueryBuilder $queryBuilder, $dqlAlias)
43
    {
44
        call_user_func_array([$queryBuilder, $this->type], [$this->select]);
45
    }
46
47
    /**
48
     * @param string $type
49
     *
50
     * @throws InvalidArgumentException
51
     */
52 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...
53
    {
54
        if (!in_array($type, self::$types, true)) {
55
            throw new InvalidArgumentException(sprintf(
56
                '"%s" is not a valid type! Valid types: %s',
57
                $type,
58
                implode(', ', self::$types)
59
            ));
60
        }
61
62
        $this->type = $type;
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function isSatisfiedBy($value)
69
    {
70
        return true;
71
    }
72
}
73