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 (#941)
by Henrique
03:04 queued 45s
created

Not::setName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
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
use Respect\Validation\Validatable;
18
19
class Not extends AbstractRule
20
{
21
    public $rule;
22
23 10
    public function __construct(Validatable $rule)
24
    {
25 10
        $this->rule = $rule;
26 10
    }
27
28 5
    public function setName($name)
29
    {
30 5
        $this->rule->setName($name);
31
32 5
        return parent::setName($name);
33
    }
34
35 4
    public function validate($input): bool
36
    {
37 4
        return false === $this->rule->validate($input);
38
    }
39
40 4
    public function assert($input): void
41
    {
42 4
        if ($this->validate($input)) {
43
            return;
44
        }
45
46 4
        $rule = $this->rule;
47 4
        if ($rule instanceof AllOf) {
48 2
            $rule = $this->absorbAllOf($rule, $input);
49
        }
50
51
        throw $rule
52 4
            ->reportError($input)
53 4
            ->setMode(ValidationException::MODE_NEGATIVE);
54
    }
55
56 2
    private function absorbAllOf(AllOf $rule, $input)
57
    {
58 2
        $rules = $rule->getRules();
59 2
        while (($current = array_shift($rules))) {
60 2
            $rule = $current;
61 2
            if (!$rule instanceof AllOf) {
62 2
                continue;
63
            }
64
65
            if (!$rule->validate($input)) {
66
                continue;
67
            }
68
69
            $rules = $rule->getRules();
70
        }
71
72 2
        return $rule;
73
    }
74
}
75