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

Result::mergeProperties()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
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
     * Initializes the object.
50
     *
51
     * @param bool   $isValid
52
     * @param mixed  $input
53
     * @param Rule   $rule
54
     * @param array  $properties
55
     * @param Result $child
56
     * @param Result ...$child2
57
     */
58 15
    public function __construct(bool $isValid, $input, Rule $rule, array $properties = [], Result ...$child)
59
    {
60 15
        $this->isValid = $isValid;
61 15
        $this->input = $input;
62 15
        $this->rule = $rule;
63 15
        $this->properties = $properties;
64 15
        $this->children = $child;
65 15
    }
66
67
    /**
68
     * Returns whether the result is valid or not.
69
     *
70
     * @return bool
71
     */
72 3
    public function isValid(): bool
73
    {
74 3
        return $this->isValid;
75
    }
76
77
    /**
78
     * Returns the input that was used on the validation.
79
     *
80
     * @return mixed
81
     */
82 3
    public function getInput()
83
    {
84 3
        return $this->input;
85
    }
86
87
    /**
88
     * Returns the rule that performed the validation.
89
     *
90
     * @return Rule
91
     */
92 3
    public function getRule(): Rule
93
    {
94 3
        return $this->rule;
95
    }
96
97
    /**
98
     * Returns the children of the result.
99
     *
100
     * @return Result[]
101
     */
102 3
    public function getChildren(): array
103
    {
104 3
        return $this->children;
105
    }
106
107
    /**
108
     * Returns the properties of the result.
109
     *
110
     * @return array
111
     */
112 8
    public function getProperties(): array
113
    {
114 8
        return $this->properties;
115
    }
116
117
    /**
118
     * Creates a new object with the defined properties.
119
     *
120
     * @param array $properties
121
     *
122
     * @return Result
123
     */
124 6
    public function mergeProperties(array $properties): Result
125
    {
126 6
        $result = clone $this;
127 6
        $result->properties = $properties + $this->getProperties();
128
129 6
        return $result;
130
    }
131
132
    /**
133
     * Creates a new object with the inverted validation.
134
     *
135
     * @return Result
136
     */
137 6
    public function invert(): Result
138
    {
139 6
        $result = clone $this;
140 6
        $result->isValid = !$result->isValid;
141
142 6
        return $result;
143
    }
144
}
145