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

Passed
Push — master ( 8d44bc...60e3fc )
by Henrique
02:27
created

Between::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.5

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 3
cts 6
cp 0.5
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 3
crap 2.5
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\ComponentException;
17
use Respect\Validation\Helpers\ComparisonHelper;
18
use function Respect\Stringifier\stringify;
19
20
/**
21
 * Validates whether the input is between two other values.
22
 *
23
 * @author Alexandre Gomes Gaigalas <[email protected]>
24
 * @author Henrique Moody <[email protected]>
25
 */
26
final class Between extends AbstractRule
27
{
28
    use ComparisonHelper;
29
30
    /**
31
     * @var mixed
32
     */
33
    private $minimum;
34
35
    /**
36
     * @var mixed
37
     */
38
    private $maximum;
39
40
    /**
41
     * @var bool
42
     */
43
    private $inclusive;
44
45
    /**
46
     * Initializes the rule.
47
     *
48
     * @param mixed $minimum
49
     * @param mixed $maximum
50
     * @param bool $inclusive
51
     *
52
     * @throws ComponentException
53
     */
54 2
    public function __construct($minimum, $maximum, bool $inclusive = true)
55
    {
56 2
        if ($this->toComparable($minimum) >= $this->toComparable($maximum)) {
57 2
            throw new ComponentException(stringify($minimum).' cannot be less than or equals to '.stringify($maximum));
58
        }
59
60
        $this->minimum = $minimum;
61
        $this->maximum = $maximum;
62
        $this->inclusive = $inclusive;
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68 19
    public function validate($input): bool
69
    {
70 19
        $rule = new AllOf(
71 19
            new Min($this->minimum, $this->inclusive),
72 19
            new Max($this->maximum, $this->inclusive)
73
        );
74
75 19
        return $rule->validate($input);
76
    }
77
}
78