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 ( 04b3c7...10ce81 )
by Henrique
02:28
created

Between::validate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
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
declare(strict_types=1);
13
14
namespace Respect\Validation\Rules;
15
16
use Respect\Validation\Exceptions\ComponentException;
17
use Respect\Validation\Helpers\ComparisonHelper;
18
19
/**
20
 * Validates whether the input is between two other values.
21
 *
22
 * @author Alexandre Gomes Gaigalas <[email protected]>
23
 * @author Henrique Moody <[email protected]>
24
 */
25
final class Between extends AbstractEnvelope
26
{
27
    use ComparisonHelper;
28
29
    /**
30
     * Initializes the rule.
31
     *
32
     * @param mixed $minimum
33
     * @param mixed $maximum
34
     * @param bool $inclusive
35
     *
36
     * @throws ComponentException
37
     */
38 10
    public function __construct($minimum, $maximum, bool $inclusive = true)
39
    {
40 10
        if ($this->toComparable($minimum) >= $this->toComparable($maximum)) {
41 2
            throw new ComponentException('Minimum cannot be less than or equals to maximum');
42
        }
43
44 8
        parent::__construct(
45 8
            new AllOf(
46 8
                new Min($minimum, $inclusive),
47 8
                new Max($maximum, $inclusive)
48
            ),
49
            [
50 8
                'minimum' => $minimum,
51 8
                'maximum' => $maximum,
52 8
                'inclusive' => $inclusive,
53
            ]
54
        );
55 8
    }
56
}
57