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 — master (#923)
by lee
03:57
created

AnyOf::check()   B

Complexity

Conditions 5
Paths 7

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 10
cts 10
cp 1
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 10
nc 7
nop 1
crap 5
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
declare(strict_types=1);
13
14
namespace Respect\Validation\Rules;
15
16
use Respect\Validation\Exceptions\ValidationException;
17
18
class AnyOf extends AbstractComposite
19
{
20 2
    public function assert($input): void
21
    {
22 2
        $validators = $this->getRules();
23 2
        $exceptions = $this->validateRules($input);
24 2
        $numRules = count($validators);
25 2
        $numExceptions = count($exceptions);
26 2
        if ($numExceptions === $numRules) {
27 1
            throw $this->reportError($input)->setRelated($exceptions);
0 ignored issues
show
Bug introduced by
The method setRelated() does not exist on Respect\Validation\Exceptions\ValidationException. It seems like you code against a sub-type of Respect\Validation\Exceptions\ValidationException such as Respect\Validation\Excep...stedValidationException. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
            throw $this->reportError($input)->/** @scrutinizer ignore-call */ setRelated($exceptions);
Loading history...
28
        }
29 1
    }
30
31 3
    public function validate($input): bool
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 3
    public function check($input): void
43
    {
44 3
        foreach ($this->getRules() as $v) {
45
            try {
46 2
                $v->check($input);
47
48 1
                return;
49 2
            } catch (ValidationException $e) {
50 2
                if (!isset($firstException)) {
51 2
                    $firstException = $e;
52
                }
53
            }
54
        }
55
56 2
        if (isset($firstException)) {
57 1
            throw $firstException;
58
        }
59
60 1
        throw $this->reportError($input);
61
    }
62
}
63