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

EquatableCollectionContains   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 1
Metric Value
wmc 10
c 3
b 1
f 1
lcom 1
cbo 1
dl 0
loc 50
ccs 18
cts 18
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A matches() 0 12 4
A failureDescription() 0 12 3
A collectionContainsAnEqualEquatableObject() 0 10 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