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 (#678)
by Henrique
02:51
created

AllOf::assert()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

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