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 ( 084f8a...9eee7f )
by Jasper
03:17
created

collectionContainsAnEqualEquatableObject()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
cc 3
eloc 5
nc 3
nop 1
crap 3
1
<?php
2
3
/**
4
 * @license https://github.com/f500/equatable/blob/master/LICENSE MIT
5
 */
6
7
namespace F500\Equatable\PHPUnit\Constraint;
8
9
use F500\Equatable\Equatable;
10
use F500\Equatable\EquatableMap;
11
use F500\Equatable\EquatableVector;
12
13
/**
14
 * @copyright Copyright (c) 2015 Future500 B.V.
15
 * @author    Jasper N. Brouwer <[email protected]>
16
 */
17
final class EquatableCollectionContains extends \PHPUnit_Framework_Constraint_TraversableContains
18
{
19
    /**
20
     * @inheritdoc
21
     */
22 27
    protected function matches($other)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
23
    {
24 27
        if ($other instanceof EquatableMap || $other instanceof EquatableVector) {
25 15
            return $other->contains($this->value);
26
        }
27
28 12
        if ($this->value instanceof Equatable) {
29 6
            return $this->collectionContainsAnEqualEquatableObject($other);
30
        }
31
32 6
        return parent::matches($other);
33
    }
34
35
    /**
36
     * @inheritdoc
37
     */
38 12
    protected function failureDescription($other)
39
    {
40 12
        if ($other instanceof EquatableMap) {
41 3
            return 'an equatable map ' . $this->toString();
42
        }
43
44 9
        if ($other instanceof EquatableVector) {
45 3
            return 'an equatable vector ' . $this->toString();
46
        }
47
48 6
        return parent::failureDescription($other);
49
    }
50
51
    /**
52
     * @param \Traversable|array $other
53
     *
54
     * @return bool
55
     */
56 6
    private function collectionContainsAnEqualEquatableObject($other)
57
    {
58 6
        foreach ($other as $element) {
59 6
            if ($this->value->equals($element)) {
60 3
                return true;
61
            }
62 3
        }
63
64 3
        return false;
65
    }
66
}
67