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 (#74)
by Simone
03:04
created

Parameter   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 57
rs 10
c 0
b 0
f 0
wmc 8

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 3 1
A withKeyAndValue() 0 5 1
A __construct() 0 4 1
A getKey() 0 3 1
B box() 0 27 4
1
<?php
2
3
namespace Mado\QueryBundle\Queries\Objects;
4
5
final class Parameter
6
{
7
    private $key;
8
9
    private $value;
10
11
    public static function withKeyAndValue(
12
        string $key,
13
        string $value
14
    ) : Parameter {
15
        return new self($key, $value);
16
    }
17
18
    public static function box(array $params) : Parameter
19
    {
20
        $fieldName          = $params['fieldName'];
21
        $filterAndOperator  = $params['filterAndOperator'];
22
        $op                 = $params['op'];
23
        $operator           = $params['operator'];
24
        $salt               = $params['salt'];
25
        $value              = $params['value'];
26
27
        if (isset($operator['substitution_pattern'])) {
28
            $isSingleValue = isset($filterAndOperator[1])
29
                && $op->isListOrNlist();
30
31
            if ($isSingleValue) {
32
                $value = str_replace(
33
                    '{string}',
34
                    $value,
35
                    $operator['substitution_pattern']
36
                );
37
            } else {
38
                $value = explode(',', $value);
39
            }
40
        }
41
42
        return new self(
43
            'field_' . $fieldName . $salt,
44
            $value
45
        );
46
    }
47
48
    private function __construct($key, $value)
49
    {
50
        $this->key   = $key;
51
        $this->value = $value;
52
    }
53
54
    public function getKey() : string
55
    {
56
        return $this->key;
57
    }
58
59
    public function getValue() : string
60
    {
61
        return $this->value;
62
    }
63
}
64