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.
Test Failed
Pull Request — master (#37)
by Simone
08:17
created

Operator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Mado\QueryBundle\Objects;
4
5
use Mado\QueryBundle\Vocabulary\Operators;
6
7
final class Operator
8
{
9
    private $operator;
10
11
    private function __construct(array $params)
12
    {
13
        $this->operator = $params['operator'];
14
    }
15
16
    public static function getDefault() : Operator
17
    {
18
        $operator = Operators::getDefaultOperator();
19
20
        return new self([
21
            'operator' => $operator,
22
        ]);
23
    }
24
25
    public function getMeta() : string
26
    {
27
        return $this->operator['meta'];
28
    }
29
30
    public static function fromRawValue(array $operator) : Operator
31
    {
32
        if (!isset($operator['meta'])) {
33
            throw new \RuntimeException(
34
                'Oops! Raw operator must contain `meta` parameter'
35
            );
36
        }
37
38
        return new self([
39
            'operator' => $operator,
40
        ]);
41
    }
42
43
    public static function fromFilteringObject(
44
        FilteringObject $filteringObject
45
    ) : Operator {
46
        if(true === $filteringObject->hasOperator()){
47
            $operatorName = $filteringObject->getOperator();
48
            $operator = Operators::get($operatorName);
49
50
            return new self([
51
                'operator' => $operator,
52
            ]);
53
        }
54
55
        return Operator::getDefault();
56
    }
57
58
    public function getRawValue() : array
59
    {
60
        return $this->operator;
61
    }
62
63
    public function haveSubstitutionPattern() : bool
64
    {
65
        return isset($this->operator['substitution_pattern']);
66
    }
67
68
    public function getSubstitutionPattern() : string
69
    {
70
        if ($this->haveSubstitutionPattern()) {
71
            return $this->operator['substitution_pattern'];
72
        }
73
74
        throw new \RuntimeException(
75
            'Oops! Current operator have not substitution pattern.'
76
        );
77
    }
78
}
79