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 (#663)
by Henrique
04:47
created

AllOf::assert()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
ccs 11
cts 11
cp 1
rs 9.4285
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\Exceptions\ValidationException;
15
16
class AllOf extends AbstractComposite
17
{
18 6
    public function assert($input)
19
    {
20 6
        $exceptions = $this->validateRules($input);
21 6
        $numRules = count($this->rules);
22 6
        $numExceptions = count($exceptions);
23
        $summary = [
24 6
            'total' => $numRules,
25 6
            'failed' => $numExceptions,
26 6
            'passed' => $numRules - $numExceptions,
27 6
        ];
28 6
        if (!empty($exceptions)) {
29 5
            throw $this->reportError($input, $summary)->setRelated($exceptions);
30
        }
31
32 1
        return true;
33
    }
34
35 11
    public function check($input)
36
    {
37 11
        $rules = $this->getRules();
38
        try {
39 11
            foreach ($rules as $rule) {
40 11
                $rule->check($input);
41 9
            }
42 11
        } catch (ValidationException $exception) {
43 10
            if (count($rules) == 1 && $this->template) {
44
                $exception->setTemplate($this->template);
45
            }
46
47 10
            throw $exception;
48
        }
49
50 1
        return true;
51
    }
52
53 16
    public function validate($input)
54
    {
55 16
        foreach ($this->getRules() as $rule) {
56 16
            if (!$rule->validate($input)) {
57 15
                return false;
58
            }
59 13
        }
60
61 1
        return true;
62
    }
63
}
64