Completed
Push — master ( 90a4d3...4d725e )
by Jean-Christophe
01:38
created

RangeValidator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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