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

AbstractComparison   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 9
dl 0
loc 43
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A validate() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Respect\Validation\Rules;
6
7
use Respect\Validation\Helpers\ComparisonHelper;
8
9
abstract class AbstractComparison extends AbstractRule
10
{
11
    use ComparisonHelper;
12
13
    /**
14
     * @var mixed
15
     */
16
    private $compareTo;
17
18
    /**
19
     * Initializes the rule by setting the value to be compared to the input.
20
     *
21
     * @param mixed $maxValue
22
     */
23 12
    public function __construct($maxValue)
24
    {
25 12
        $this->compareTo = $maxValue;
26 12
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 82
    public function validate($input): bool
32
    {
33 82
        $left = $this->toComparable($input);
34 82
        $right = $this->toComparable($this->compareTo);
35
36 82
        if (!$this->isAbleToCompareValues($left, $right)) {
37 9
            return false;
38
        }
39
40 73
        return $this->compare($left, $right);
41
    }
42
43
    /**
44
     * Compare both values and return whether the comparison is valid or not.
45
     *
46
     * @param mixed $left
47
     * @param mixed $right
48
     *
49
     * @return bool
50
     */
51
    abstract protected function compare($left, $right): bool;
52
}
53