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 (#923)
by lee
03:57
created

When   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 95.65%

Importance

Changes 0
Metric Value
wmc 8
dl 0
loc 47
ccs 22
cts 23
cp 0.9565
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 7 2
A __construct() 0 10 2
A check() 0 9 2
A assert() 0 9 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
declare(strict_types=1);
13
14
namespace Respect\Validation\Rules;
15
16
use Respect\Validation\Exceptions\AlwaysInvalidException;
17
use Respect\Validation\Validatable;
18
19
class When extends AbstractRule
20
{
21
    public $when;
22
    public $then;
23
    public $else;
24
25 8
    public function __construct(Validatable $when, Validatable $then, Validatable $else = null)
26
    {
27 8
        $this->when = $when;
28 8
        $this->then = $then;
29 8
        if (null === $else) {
30 1
            $else = new AlwaysInvalid();
31 1
            $else->setTemplate(AlwaysInvalidException::SIMPLE);
32
        }
33
34 8
        $this->else = $else;
35 8
    }
36
37 10
    public function validate($input): bool
38
    {
39 10
        if ($this->when->validate($input)) {
40 9
            return $this->then->validate($input);
41
        }
42
43 1
        return $this->else->validate($input);
44
    }
45
46 3
    public function assert($input): void
47
    {
48 3
        if ($this->when->validate($input)) {
49 2
            $this->then->assert($input);
50
51 1
            return;
52
        }
53
54 1
        $this->else->assert($input);
55
    }
56
57 3
    public function check($input): void
58
    {
59 3
        if ($this->when->validate($input)) {
60 2
            $this->then->check($input);
61
62 1
            return;
63
        }
64
65 1
        $this->else->check($input);
66
    }
67
}
68