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.
Passed
Push — master ( 1ab2ca...448645 )
by Simone
07:34 queued 05:12
created

Operator   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 69
rs 10
c 0
b 0
f 0
ccs 31
cts 31
cp 1
wmc 11

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefault() 0 6 1
A __construct() 0 3 1
A haveSubstitutionPattern() 0 3 1
A fromFilteringObject() 0 13 2
A getSubstitutionPattern() 0 8 2
A getMeta() 0 3 1
A fromRawValue() 0 10 2
A getRawValue() 0 3 1
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 7
    private function __construct(array $params)
12
    {
13 7
        $this->operator = $params['operator'];
14 7
    }
15
16 3
    public static function getDefault() : Operator
17
    {
18 3
        $operator = Operators::getDefaultOperator();
19
20 3
        return new self([
21 3
            'operator' => $operator,
22
        ]);
23
    }
24
25 2
    public function getMeta() : string
26
    {
27 2
        return $this->operator['meta'];
28
    }
29
30 4
    public static function fromRawValue(array $operator) : Operator
31
    {
32 4
        if (!isset($operator['meta'])) {
33 1
            throw new \RuntimeException(
34 1
                'Oops! Raw operator must contain `meta` parameter'
35
            );
36
        }
37
38 3
        return new self([
39 3
            'operator' => $operator,
40
        ]);
41
    }
42
43 3
    public static function fromFilteringObject(
44
        FilteringObject $filteringObject
45
    ) : Operator {
46 3
        if(true === $filteringObject->hasOperator()){
47 2
            $operatorName = $filteringObject->getOperator();
48 2
            $operator = Operators::get($operatorName);
49
50 2
            return new self([
51 2
                'operator' => $operator,
52
            ]);
53
        }
54
55 1
        return Operator::getDefault();
56
    }
57
58 1
    public function getRawValue() : array
59
    {
60 1
        return $this->operator;
61
    }
62
63 2
    public function haveSubstitutionPattern() : bool
64
    {
65 2
        return isset($this->operator['substitution_pattern']);
66
    }
67
68 2
    public function getSubstitutionPattern() : string
69
    {
70 2
        if ($this->haveSubstitutionPattern()) {
71 1
            return $this->operator['substitution_pattern'];
72
        }
73
74 1
        throw new \RuntimeException(
75 1
            'Oops! Current operator have not substitution pattern.'
76
        );
77
    }
78
}
79