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.

QueryBuilderOptions::fromArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Mado\QueryBundle\Queries;
4
5
class QueryBuilderOptions
6
{
7
    private $options;
8
9 14
    private function __construct(array $options)
10
    {
11 14
        $this->options = $options;
12 14
    }
13
14 14
    public static function fromArray(array $options)
15
    {
16 14
        return new self($options);
17
    }
18
19 6
    public function get($option, $defaultValue = null)
20
    {
21 6
        $this->validateOption($option, $defaultValue);
22
23
        if (
24 6
            !isset($this->options[$option])
25 6
            || empty($this->options[$option])
26
        ) {
27 4
            return $defaultValue;
28
        }
29
30 5
        return $this->options[$option];
31
    }
32
33 1
    public function getAndFilters()
34
    {
35 1
        return $this->get('filters', []);
36
    }
37
38 1
    public function getOrFilters()
39
    {
40 1
        return $this->get('orFilters', []);
41
    }
42
43 1
    public function getSorting()
44
    {
45 1
        return $this->get('sorting', []);
46
    }
47
48 1
    public function getRel()
49
    {
50 1
        return $this->get('rel', []);
51
    }
52
53 1
    public function getPrinting()
54
    {
55 1
        return $this->get('printing', []);
56
    }
57
58 1
    public function getSelect()
59
    {
60 1
        return $this->get('select');
61
    }
62
63 6
    public function validateOption($option, $defaultValue)
64
    {
65
        $optionIsDefinedNegativeAndNotNull = (
0 ignored issues
show
introduced by
Consider adding parentheses for clarity. Current Interpretation: $optionIsDefinedNegative... $defaultValue == null), Probably Intended Meaning: $optionIsDefinedNegative... $defaultValue == null)
Loading history...
66 6
            !isset($this->options[$option])
67 6
            || $this->options[$option] < 0
68 6
        ) && $defaultValue == null;
69
70 6
        if ('limit' == $option && $optionIsDefinedNegativeAndNotNull) {
71 4
            $this->options[$option] = PHP_INT_MAX;
72
        }
73 6
    }
74
75
    public function requireJustCount()
76
    {
77
        return isset($this->options['justCount'])
78
            && $this->options['justCount'] === 'true';
79
    }
80
}
81