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
Pull Request — master (#37)
by Simone
01:54
created

Operator::getRawValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
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 fromRawValue(array $operator) : Operator
17
    {
18
        return new self([
19
            'operator' => $operator,
20
        ]);
21
    }
22
23
    public static function fromFilteringObject(
24
        FilteringObject $filteringObject
25
    ) : Operator {
26
        $operator = Operators::get($filteringObject->getOperator());
27
28
        return new self([
29
            'operator' => $operator,
30
        ]);
31
    }
32
33
    public static function getDefault()
34
    {
35
        $operator = Operators::getDefaultOperator();
36
37
        return new self([
38
            'operator' => $operator,
39
        ]);
40
    }
41
42
    public function getRawValue()
43
    {
44
        return $this->operator;
45
    }
46
47
    public function getMeta()
48
    {
49
        $this->ensureMetaIsDefined();
50
51
        return $this->operator['meta'];
52
    }
53
54
    private function ensureMetaIsDefined()
55
    {
56
        if (!isset($this->operator['meta'])) {
57
            throw new \RuntimeException(
58
                'Oops! Invalid meta value'
59
            );
60
        }
61
    }
62
}
63