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...4184ab )
by Henrique
03:41
created

Result::isInverted()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
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;
13
14
/**
15
 * Handles validation's results.
16
 *
17
 * @author Henrique Moody <[email protected]>
18
 *
19
 * @since 2.0.0
20
 */
21
final class Result
22
{
23
    /**
24
     * @var bool
25
     */
26
    private $isValid;
27
28
    /**
29
     * @var mixed
30
     */
31
    private $input;
32
33
    /**
34
     * @var Rule
35
     */
36
    private $rule;
37
38
    /**
39
     * @var Result[]
40
     */
41
    private $children;
42
43
    /**
44
     * @var array
45
     */
46
    private $properties;
47
48
    /**
49
     * @var bool
50
     */
51
    private $isInverted = false;
52
53
    /**
54
     * Initializes the object.
55
     *
56
     * @param bool   $isValid
57
     * @param mixed  $input
58
     * @param Rule   $rule
59
     * @param array  $properties
60
     * @param Result $child
61
     * @param Result ...$child2
62
     */
63 15
    public function __construct(bool $isValid, $input, Rule $rule, array $properties = [], Result ...$child)
64
    {
65 15
        $this->isValid = $isValid;
66 15
        $this->input = $input;
67 15
        $this->rule = $rule;
68 15
        $this->properties = $properties;
69 15
        $this->children = $child;
70 15
    }
71
72
    /**
73
     * Returns whether the result is valid or not.
74
     *
75
     * @return bool
76
     */
77 2
    public function isValid(): bool
78
    {
79 2
        return $this->isValid;
80
    }
81
82
    /**
83
     * Returns the input that was used on the validation.
84
     *
85
     * @return mixed
86
     */
87 2
    public function getInput()
88
    {
89 2
        return $this->input;
90
    }
91
92
    /**
93
     * Returns the rule that performed the validation.
94
     *
95
     * @return Rule
96
     */
97 2
    public function getRule(): Rule
98
    {
99 2
        return $this->rule;
100
    }
101
102
    /**
103
     * Returns the children of the result.
104
     *
105
     * @return Result[]
106
     */
107 2
    public function getChildren(): array
108
    {
109 2
        return $this->children;
110
    }
111
112
    /**
113
     * Returns the properties of the result.
114
     *
115
     * @return array
116
     */
117 3
    public function getProperties(): array
118
    {
119 3
        return $this->properties;
120
    }
121
122
    /**
123
     * Returns whether the result is inverted or not.
124
     *
125
     * @return bool
126
     */
127 3
    public function isInverted(): bool
128
    {
129 3
        return $this->isInverted;
130
    }
131
132
    /**
133
     * Creates a new object with the inverted validation.
134
     *
135
     * @return Result
136
     */
137 9
    public function invert(): Result
138
    {
139 9
        $result = clone $this;
140 9
        $result->isValid = !$result->isValid;
141 9
        $result->isInverted = !$result->isInverted;
142
143 9
        return $result;
144
    }
145
}
146