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/additional-filters... ( 65cf7b...b8640f )
by Simone
03:08
created

Filter   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 95
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

10 Methods

Rating   Name   Duplication   Size   Complexity  
A box() 0 13 1
A getFieldAndOperator() 0 3 1
A getPath() 0 3 1
A getOperator() 0 3 1
A __construct() 0 6 1
A buildRawFilter() 0 3 1
A getField() 0 7 1
A withFullPath() 0 12 1
A getIds() 0 3 1
A withPath() 0 13 2
1
<?php
2
3
namespace Mado\QueryBundle\Objects;
4
5
class Filter
6
{
7
    private $rawFilter;
8
9
    private $ids;
10
11
    private $operator;
12
13 9
    public static function box(array $params)
14
    {
15 9
        $rawIds    = $params['ids'];
16 9
        $path      = $params['path'];
17
18 9
        $operator  = key($rawIds);
19 9
        $ids       = join(',', current($rawIds));
20
21 9
        return new self([
22 9
            'raw_filter' => self::buildRawFilter($path, $operator),
23 9
            'ids'        => $ids,
24 9
            'operator'   => $operator,
25 9
            'path'       => $path,
26
        ]);
27
    }
28
29 9
    private static function buildRawFilter($path, $operator)
30
    {
31 9
        return $path . '.id|' . $operator;
32
    }
33
34 9
    private function __construct(array $params)
35
    {
36 9
        $this->rawFilter = $params['raw_filter'];
37 9
        $this->ids       = $params['ids'];
38 9
        $this->operator  = $params['operator'];
39 9
        $this->path      = $params['path'];
0 ignored issues
show
Bug Best Practice introduced by
The property path does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
40 9
    }
41
42 7
    public function getFieldAndOperator()
43
    {
44 7
        return $this->rawFilter;
45
    }
46
47 6
    public function getIds()
48
    {
49 6
        return $this->ids;
50
    }
51
52 6
    public function getOperator()
53
    {
54 6
        return $this->operator;
55
    }
56
57 4
    public function getPath()
58
    {
59 4
        return $this->path;
60
    }
61
62 2
    public function withPath($path)
63
    {
64 2
        $rawFilter = self::buildRawFilter($path, $this->operator);
65
66 2
        if ($path == '') {
67 1
            $rawFilter = str_replace('.', '', $rawFilter);
68
        }
69
70 2
        return new self([
71 2
            'raw_filter' => $rawFilter,
72 2
            'ids'        => $this->ids,
73 2
            'operator'   => $this->operator,
74 2
            'path'       => $path,
75
        ]);
76
    }
77
78 1
    public function withFullPath($path)
79
    {
80 1
        $explodedPath = explode('|', $path);
81
82 1
        $path = $explodedPath[0];
83 1
        $operator = $explodedPath[1];
84
85 1
        return new self([
86 1
            'raw_filter' => join('|', $explodedPath),
87 1
            'ids'        => $this->ids,
88 1
            'operator'   => $operator,
89 1
            'path'       => $path,
90
        ]);
91
    }
92
93 4
    public function getField()
94
    {
95 4
        $explodedPath = explode('|', $this->getFieldAndOperator());
96
97 4
        $field = $explodedPath[0];
98
99 4
        return $field;
100
    }
101
}
102