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.
Completed
Push — master ( ca9b69...35d367 )
by Axel
03:00
created

ComparisonManager   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 66.67%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 53
ccs 10
cts 15
cp 0.6667
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A compare() 0 10 3
A addComparison() 0 3 1
A getAttributeManager() 0 3 1
1
<?php
2
3
namespace PhpAbac\Manager;
4
5
use PhpAbac\Comparison\ArrayComparison;
6
use PhpAbac\Comparison\BooleanComparison;
7
use PhpAbac\Comparison\DatetimeComparison;
8
use PhpAbac\Comparison\NumericComparison;
9
use PhpAbac\Comparison\StringComparison;
10
11
class ComparisonManager {
12
    /** @var \PhpAbac\Manager\AttributeManager **/
13
    protected $attributeManager;
14
    /** @var array **/
15
    protected $comparisons = [
16
        'array' => ArrayComparison::class,
17
        'boolean' => BooleanComparison::class,
18
        'datetime' => DatetimeComparison::class,
19
        'numeric' => NumericComparison::class,
20
        'string' => StringComparison::class,
21
    ];
22
    
23
    /**
24
     * @param \PhpAbac\Manager\AttributeManager $manager
25
     */
26 16
    public function __construct(AttributeManager $manager) {
27 16
        $this->attributeManager = $manager;
28 16
    }
29
    
30
    /**
31
     * @param string $type
32
     * @param string $method
33
     * @param mixed $expectedValue
34
     * @param mixed $value
35
     * @param array $extraData
36
     * @return bool
37
     */
38 2
    public function compare($type, $method, $expectedValue, $value, $extraData = []) {
39 2
        if(!isset($this->comparisons[$type])) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
40
            throw new \InvalidArgumentException('The requested comparison class does not exist');
41
        }
42 2
        $comparison = new $this->comparisons[$type]($this);
43 2
        if(!method_exists($comparison, $method)) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
44
            throw new \InvalidArgumentException('The requested comparison method does not exist');
45
        }
46 2
        return $comparison->{$method}($expectedValue, $value, $extraData);
47
    }
48
    
49
    /**
50
     * @param string $type
51
     * @param string $class
52
     */
53
    public function addComparison($type, $class) {
54
        $this->comparisons[$type] = $class;
55
    }
56
    
57
    /**
58
     * @return \PhpAbac\Manager\AttributeManager
59
     */
60 2
    public function getAttributeManager() {
61 2
        return $this->attributeManager;
62
    }
63
}