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

ArrayComparison::contains()   B

Complexity

Conditions 5
Paths 7

Size

Total Lines 21
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 18
CRAP Score 5

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 21
ccs 18
cts 18
cp 1
rs 8.7624
cc 5
eloc 15
nc 7
nop 3
crap 5
1
<?php
2
3
namespace PhpAbac\Comparison;
4
5
class ArrayComparison extends AbstractComparison
6
{
7
    /**
8
     * @param array $haystack
9
     * @param mixed  $needle
10
     *
11
     * @return bool
12
     */
13 3
    public function isIn($haystack, $needle)
14
    {
15 3
        return in_array($needle, $haystack);
16
    }
17
18
    /**
19
     * @param array $haystack
20
     * @param mixed  $needle
21
     *
22
     * @return bool
23
     */
24 1
    public function isNotIn($haystack, $needle)
25
    {
26 1
        return !$this->isIn($haystack, $needle);
27
    }
28
29
    /**
30
     * @param array $array1
31
     * @param array $array2
32
     *
33
     * @return bool
34
     */
35 2
    public function intersect($array1, $array2)
36
    {
37 2
        return count(array_intersect($array1, $array2)) > 0;
38
    }
39
40
    /**
41
     * @param array $array1
42
     * @param array $array2
43
     *
44
     * @return bool
45
     */
46 1
    public function doNotIntersect($array1, $array2)
47
    {
48 1
        return !$this->intersect($array1, $array2);
49
    }
50
    
51
    /**
52
     * @param array $policyRuleAttributes
53
     * @param array $attributes
54
     * @return boolean
55
     */
56 2
    public function contains($policyRuleAttributes, $attributes, $extraData = []) {
0 ignored issues
show
Unused Code introduced by
The parameter $attributes is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
57 2
        foreach($extraData['attribute']->getValue() as $attribute) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FOREACH keyword; 0 found
Loading history...
58 2
            $result = true;
59 2
            foreach($policyRuleAttributes as $pra) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FOREACH keyword; 0 found
Loading history...
60 2
                $attributeData = $pra->getAttribute();
61 2
                if(!$this->comparisonManager->compare(
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
62 2
                    $pra->getComparisonType(),
63 2
                    $pra->getComparison(),
64 2
                    $pra->getValue(),
65 2
                    $this->comparisonManager->getAttributeManager()->retrieveAttribute($attributeData, $extraData['user'], $attribute)
66 2
                )) {
67 2
                    $result = false;
68 2
                    break;
69
                }
70 2
            }
71 2
            if($result === true) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
72 2
                return true;
73
            }
74 2
        }
75 2
        return false;
76
    }
77
}
78