Passed
Push — master ( 3592a4...bf89a7 )
by Jean-Christophe
05:06
created

RangeValidator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 7
dl 0
loc 20
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 3 2
A __construct() 0 2 1
A getParameters() 0 2 1
1
<?php
2
3
namespace Ubiquity\contents\validation\validators\comparison;
4
5
use Ubiquity\contents\validation\validators\ValidatorHasNotNull;
6
7
/**
8
 * @author jcheron <[email protected]>
9
 *
10
 */
11
class RangeValidator extends ValidatorHasNotNull {
12
	
13
	protected $min;
14
	protected $max;
15
	
16 1
	public function __construct(){
17 1
		$this->message="This value should be between `{min}` and `{max}`";
18 1
	}
19
	
20 1
	public function validate($value) {
21 1
		parent::validate($value);
22 1
		return $value>=$this->min && $value<=$this->max;
23
	}
24
	
25
	/**
26
	 * {@inheritDoc}
27
	 * @see \Ubiquity\contents\validation\validators\Validator::getParameters()
28
	 */
29 1
	public function getParameters(): array {
30 1
		return ["min","max","value"];
31
	}
32
33
}
34
35