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
03:00
created

OneOf::check()   B

Complexity

Conditions 6
Paths 9

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 6.0359

Importance

Changes 0
Metric Value
dl 0
loc 20
ccs 9
cts 10
cp 0.9
rs 8.9777
c 0
b 0
f 0
cc 6
nc 9
nop 1
crap 6.0359
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