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 — 0.9 (#694)
by
unknown
03:32
created

When::assert()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
namespace Respect\Validation\Rules;
3
4
use Respect\Validation\Validatable;
5
use Respect\Validation\Exceptions\AlwaysInvalidException;
6
7
class When extends AbstractRule
8
{
9
    public $when;
10
    public $then;
11
    public $else;
12
13 9
    public function __construct(Validatable $when, Validatable $then, Validatable $else = null)
14
    {
15 9
        $this->when = $when;
16 9
        $this->then = $then;
17 9
        if (null === $else) {
18 3
            $else = new AlwaysInvalid();
19 3
            $else->setTemplate(AlwaysInvalidException::SIMPLE);
20 3
        }
21
22 9
        $this->else = $else;
23 9
    }
24
25 4
    public function validate($input)
26
    {
27 4
        if ($this->when->validate($input)) {
28 3
            return $this->then->validate($input);
29
        }
30
31 2
        return $this->else->validate($input);
32
    }
33
34 3
    public function assert($input)
35
    {
36 3
        if ($this->when->validate($input)) {
37 1
            return $this->then->assert($input);
38
        }
39
40 2
        return $this->else->assert($input);
41
    }
42
43 2
    public function check($input)
44
    {
45 2
        if ($this->when->validate($input)) {
46 1
            return $this->then->check($input);
47
        }
48
49 1
        return $this->else->check($input);
50
    }
51
}
52