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 — 1.1 (#1169)
by Henrique
02:59
created

Not   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 88.46%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 3
dl 0
loc 56
ccs 23
cts 26
cp 0.8846
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setName() 0 6 1
A validate() 0 4 1
A assert() 0 15 3
A absorbAllOf() 0 18 4
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
use Respect\Validation\Validatable;
16
17
class Not extends AbstractRule
18
{
19
    public $rule;
20
21 18
    public function __construct(Validatable $rule)
22
    {
23 18
        $this->rule = $rule;
24 18
    }
25
26 5
    public function setName($name)
27
    {
28 5
        $this->rule->setName($name);
29
30 5
        return parent::setName($name);
31
    }
32
33 12
    public function validate($input)
34
    {
35 12
        return (false == $this->rule->validate($input));
36
    }
37
38 12
    public function assert($input)
39
    {
40 12
        if ($this->validate($input)) {
41 8
            return true;
42
        }
43
44 4
        $rule = $this->rule;
45 4
        if ($rule instanceof AllOf) {
46 2
            $rule = $this->absorbAllOf($rule, $input);
47
        }
48
49
        throw $rule
50 4
            ->reportError($input)
51 4
            ->setMode(ValidationException::MODE_NEGATIVE);
52
    }
53
54 2
    private function absorbAllOf(AllOf $rule, $input)
55
    {
56 2
        $rules = $rule->getRules();
57 2
        while (($current = array_shift($rules))) {
58 2
            $rule = $current;
59 2
            if (!$rule instanceof AllOf) {
60 2
                continue;
61
            }
62
63
            if (!$rule->validate($input)) {
64
                continue;
65
            }
66
67
            $rules = $rule->getRules();
68
        }
69
70 2
        return $rule;
71
    }
72
}
73