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 (#678)
by Henrique
03:24
created

Result::mergeProperties()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
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
 * Class that handles validation's results.
16
 *
17
 * @author Henrique Moody <[email protected]>
18
 */
19
final class Result
20
{
21
    /**
22
     * @var bool
23
     */
24
    private $isValid;
25
26
    /**
27
     * @var mixed
28
     */
29
    private $input;
30
31
    /**
32
     * @var Rule
33
     */
34
    private $rule;
35
36
    /**
37
     * @var Rule[]
38
     */
39
    private $children;
40
41
    /**
42
     * @var array
43
     */
44
    private $properties;
45
46 15
    public function __construct(bool $isValid, $input, Rule $rule, array $properties = [], Result ...$children)
47
    {
48 15
        $this->isValid = $isValid;
49 15
        $this->input = $input;
50 15
        $this->rule = $rule;
51 15
        $this->properties = $properties;
52 15
        $this->children = $children;
0 ignored issues
show
Documentation Bug introduced by
It seems like $children of type array<integer,object<Respect\Validation\Result>> is incompatible with the declared type array<integer,object<Respect\Validation\Rule>> of property $children.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
53 15
    }
54
55 13
    public function isValid(): bool
56
    {
57 13
        return $this->isValid;
58
    }
59
60 13
    public function getInput()
61
    {
62 13
        return $this->input;
63
    }
64
65 13
    public function getRule(): Rule
66
    {
67 13
        return $this->rule;
68
    }
69
70 13
    public function getChildren(): array
71
    {
72 13
        return $this->children;
73
    }
74
75 13
    public function getProperties(): array
76
    {
77 13
        return $this->properties;
78
    }
79
80 6
    public function mergeProperties(array $properties = []): Result
81
    {
82 6
        return new self(
83 6
            $this->isValid(),
84 6
            $this->getInput(),
85 6
            $this->getRule(),
86 6
            $properties + $this->getProperties(),
87 6
            ...$this->getChildren()
88
        );
89
    }
90
91 6
    public function invert(): Result
92
    {
93 6
        return new self(
94 6
            !$this->isValid(),
95 6
            $this->getInput(),
96 6
            $this->getRule(),
97 6
            $this->getProperties(),
98 6
            ...$this->getChildren()
99
        );
100
    }
101
}
102