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 — refactoring/keep-options-separ... ( b55c46 )
by Simone
06:00
created

QueryBuilderOptions   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Test Coverage

Coverage 53.85%

Importance

Changes 0
Metric Value
wmc 12
dl 0
loc 65
ccs 14
cts 26
cp 0.5385
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 10 3
A getRel() 0 3 1
A getSorting() 0 3 1
A fromArray() 0 3 1
A getPrinting() 0 3 1
A getOrFilters() 0 3 1
A __construct() 0 3 1
A with() 0 5 1
A getSelect() 0 3 1
A getAndFilters() 0 3 1
1
<?php
2
3
namespace Mado\QueryBundle\Queries;
4
5
class QueryBuilderOptions
6
{
7
    const FILTER_AND = 'filters';
8
9
    const FILTER_OR = 'orFilters';
10
11
    private $options;
12
13 28
    private function __construct(array $options)
14
    {
15 28
        $this->options = $options;
16 28
    }
17
18 28
    public static function fromArray(array $options)
19
    {
20 28
        return new self($options);
21
    }
22
23 15
    public function get($option, $defaultValue = null)
24
    {
25
        if (
26 15
            !isset($this->options[$option])
27 15
            || empty($this->options[$option])
28
        ) {
29 13
            return $defaultValue;
30
        }
31
32 15
        return $this->options[$option];
33
    }
34
35
    public function getAndFilters()
36
    {
37
        return $this->get(self::FILTER_AND, []);
38
    }
39
40
    public function getOrFilters()
41
    {
42
        return $this->get(self::FILTER_OR, []);
43
    }
44
45
    public function getSorting()
46
    {
47
        return $this->get('sorting', []);
48
    }
49
50
    public function getRel()
51
    {
52
        return $this->get('rel');
53
    }
54
55
    public function getPrinting()
56
    {
57
        return $this->get('printing', []);
58
    }
59
60
    public function getSelect()
61
    {
62
        return $this->get('select');
63
    }
64
65 2
    public function with($key, $value)
66
    {
67 2
        return new self(array_merge(
68 2
            $this->options,
69 2
            [$key => $value]
70
        ));
71
    }
72
}
73