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
Push — 2.0 ( e6a123...4184ab )
by Henrique
03:41
created

AnyOf::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
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\Result;
15
use Respect\Validation\Rule;
16
17
/**
18
 * Validates if none of the given validators validate.
19
 *
20
 * @author Alexandre Gomes Gaigalas <[email protected]>
21
 * @author Henrique Moody <[email protected]>
22
 *
23
 * @since 0.3.9
24
 */
25
final class AnyOf implements Rule
26
{
27
    /**
28
     * @var Rule[]
29
     */
30
    private $rules = [];
31
32
    /**
33
     * Initializes the rule.
34
     *
35
     * @param Rule $rule
36
     * @param Rule ...$rule2
37
     */
38 1
    public function __construct(Rule ...$rule)
39
    {
40 1
        $this->rules = $rule;
41 1
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 29
    public function validate($input): Result
47
    {
48 29
        $isValid = false;
49 29
        $childrenResults = [];
50 29
        foreach ($this->rules as $rule) {
51 25
            $childResult = $rule->validate($input);
52
53 25
            $isValid = $childResult->isValid() || $isValid;
54 25
            $childrenResults[] = $childResult;
55
        }
56
57 29
        return new Result($isValid, $input, $this, [], ...$childrenResults);
58
    }
59
}
60