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... ( 87af10...f55b67 )
by Simone
02:59
created

Filter   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
dl 0
loc 78
ccs 41
cts 41
cp 1
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A box() 0 12 1
A getPath() 0 3 1
A getRawFilter() 0 3 1
A getOperator() 0 3 1
A __construct() 0 6 1
A buildRawFilter() 0 3 1
A withFullPath() 0 12 1
A getIds() 0 3 1
A withPath() 0 7 1
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 8
    public static function box(array $params)
14
    {
15 8
        $rawIds    = $params['ids'];
16 8
        $operator  = key($rawIds);
17 8
        $ids       = join(',', current($rawIds));
18 8
        $path      = $params['path'];
19
20 8
        return new self([
21 8
            'raw_filter' => self::buildRawFilter($path, $operator),
22 8
            'ids'        => $ids,
23 8
            'operator'   => $operator,
24 8
            'path'       => $path,
25
        ]);
26
    }
27
28 8
    private static function buildRawFilter($path, $operator)
29
    {
30 8
        return $path . '.id|' . $operator;
31
    }
32
33 8
    private function __construct(array $params)
34
    {
35 8
        $this->rawFilter = $params['raw_filter'];
36 8
        $this->ids       = $params['ids'];
37 8
        $this->operator  = $params['operator'];
38 8
        $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...
39 8
    }
40
41 6
    public function getRawFilter()
42
    {
43 6
        return $this->rawFilter;
44
    }
45
46 6
    public function getIds()
47
    {
48 6
        return $this->ids;
49
    }
50
51 6
    public function getOperator()
52
    {
53 6
        return $this->operator;
54
    }
55
56 3
    public function getPath()
57
    {
58 3
        return $this->path;
59
    }
60
61 1
    public function withPath($path)
62
    {
63 1
        return new self([
64 1
            'raw_filter' => self::buildRawFilter($path, $this->operator),
65 1
            'ids'        => $this->ids,
66 1
            'operator'   => $this->operator,
67 1
            'path'       => $path,
68
        ]);
69
    }
70
71 1
    public function withFullPath($path)
72
    {
73 1
        $explodedPath = explode('|', $path);
74
75 1
        $path = $explodedPath[0];
76 1
        $operator = $explodedPath[1];
77
78 1
        return new self([
79 1
            'raw_filter' => join('|', $explodedPath),
80 1
            'ids'        => $this->ids,
81 1
            'operator'   => $operator,
82 1
            'path'       => $path,
83
        ]);
84
    }
85
}
86