Completed
Push — master ( 5cfdc9...6f3eaf )
by Philip
02:18
created

Between::compare()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 3
eloc 4
nc 3
nop 2
1
<?php
2
3
/*
4
 * This file is part of the Valdi package.
5
 *
6
 * (c) Philip Lehmann-Böhm <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Valdi\Validator;
13
14
/**
15
 * Validator for values between.
16
 */
17
class Between extends Comparator {
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    protected function compare($a, $parameters) {
23
        return $this->allNumeric($a, $parameters[0], $parameters[1])
24
            && $a >= $parameters[0]
25
            && $a <= $parameters[1];
26
    }
27
28
    /**
29
     * Constructor.
30
     */
31
    public function __construct() {
32
        $this->amountOfParameters = 2;
33
    }
34
}
35