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.

OnePredicate::__invoke()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 8
cts 8
cp 1
rs 9.7333
c 0
b 0
f 0
cc 4
nc 4
nop 1
crap 4
1
<?php
2
/**
3
 * This file is part of the predicates package.
4
 *
5
 * Copyright (c) dutekvejin
6
 *
7
 * For full copyright and license information, please refer to the LICENSE file,
8
 * located at the package root folder.
9
 */
10
11
namespace Dutek\Predicate;
12
13
/**
14
 * Predicate implementation that returns true if only one of the predicates return true.
15
 * If the array of predicates is empty, then this predicate returns false.
16
 *
17
 * @package Dutek\Predicate
18
 * @author Dušan Vejin <[email protected]>
19
 */
20
class OnePredicate extends AbstractQuantifierPredicate
21
{
22
    /**
23
     * Evaluates the predicate returning true if only one decorated predicate returns true.
24
     *
25
     * @param mixed $value The input value.
26
     * @return bool true if only one decorated predicate returns true
27
     */
28 7
    public function __invoke($value) : bool
29
    {
30 7
        $match = false;
31
32 7
        foreach ($this->predicates as $predicate) {
33 6
            if ($predicate($value)) {
34 4
                if ($match) {
35 2
                    return false;
36
                }
37
38 6
                $match = true;
39
            }
40
        }
41
42 5
        return $match;
43
    }
44
}
45