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 )
by Henrique
05:00
created

Not::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
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
use Respect\Validation\Validatable;
16
17
class Not extends AbstractRule
18
{
19
    public $rule;
20
21
    public function __construct(Validatable $rule)
22
    {
23
        $this->rule = $rule;
24
    }
25
26
    public function setName($name)
27
    {
28
        $this->rule->setName($name);
29
30
        return parent::setName($name);
31
    }
32
33
    public function validate($input)
34
    {
35
        return false == $this->rule->validate($input);
36
    }
37
38
    public function assert($input)
39
    {
40
        if ($this->validate($input)) {
41
            return true;
42
        }
43
44
        $rule = $this->rule;
45
        if ($rule instanceof AllOf) {
46
            $rule = $this->absorbAllOf($rule, $input);
47
        }
48
49
        throw $rule
50
            ->reportError($input)
51
            ->setMode(ValidationException::MODE_NEGATIVE);
52
    }
53
54
    private function absorbAllOf(AllOf $rule, $input)
55
    {
56
        $rules = $rule->getRules();
0 ignored issues
show
Bug introduced by
The method getRules() does not seem to exist on object<Respect\Validation\Rules\AllOf>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
57
        while (($current = array_shift($rules))) {
58
            $rule = $current;
59
            if (!$rule instanceof AllOf) {
60
                continue;
61
            }
62
63
            if (!$rule->validate($input)) {
64
                continue;
65
            }
66
67
            $rules = $rule->getRules();
0 ignored issues
show
Bug introduced by
The method getRules() does not seem to exist on object<Respect\Validation\Rules\AllOf>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
68
        }
69
70
        return $rule;
71
    }
72
}
73