Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — 1.1 (#1169)
by Henrique
02:59
created

OneOf   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 95.65%

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 2
dl 0
loc 47
ccs 22
cts 23
cp 0.9565
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A assert() 0 12 2
A validate() 0 10 3
B check() 0 20 6
1
<?php
2
3
/*
4
 * This file is part of Respect/Validation.
5
 *
6
 * (c) Alexandre Gomes Gaigalas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the "LICENSE.md"
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Respect\Validation\Rules;
13
14
use Respect\Validation\Exceptions\ValidationException;
15
16
class OneOf extends AbstractComposite
17
{
18 2
    public function assert($input)
19
    {
20 2
        $validators = $this->getRules();
21 2
        $exceptions = $this->validateRules($input);
22 2
        $numRules = count($validators);
23 2
        $numExceptions = count($exceptions);
24 2
        if ($numExceptions === $numRules) {
25 1
            throw $this->reportError($input)->setRelated($exceptions);
26
        }
27
28 1
        return true;
29
    }
30
31 3
    public function validate($input)
32
    {
33 3
        foreach ($this->getRules() as $v) {
34 3
            if ($v->validate($input)) {
35 3
                return true;
36
            }
37
        }
38
39 2
        return false;
40
    }
41
42 2
    public function check($input)
43
    {
44 2
        foreach ($this->getRules() as $v) {
45
            try {
46 2
                if ($v->check($input)) {
47 1
                    return true;
48
                }
49 2
            } catch (ValidationException $e) {
50 2
                if (!isset($firstException)) {
51 2
                    $firstException = $e;
52
                }
53
            }
54
        }
55
56 1
        if (isset($firstException)) {
57 1
            throw $firstException;
58
        }
59
60
        return false;
61
    }
62
}
63