Code Duplication    Length = 19-23 lines in 3 locations

Ubiquity/contents/validation/validators/comparison/GreaterThanOrEqualValidator.php 1 location

@@ 8-27 (lines=20) @@
5
6
use Ubiquity\contents\validation\validators\ValidatorHasNotNull;
7
8
class GreaterThanOrEqualValidator extends ValidatorHasNotNull {
9
	
10
	protected $ref;
11
	
12
	public function __construct(){
13
		$this->message="This value should be greater or equal than `{ref}`";
14
	}
15
	public function validate($value) {
16
		parent::validate($value);
17
		return $value>=$this->ref;
18
	}
19
	/**
20
	 * {@inheritDoc}
21
	 * @see \Ubiquity\contents\validation\validators\Validator::getParameters()
22
	 */
23
	public function getParameters(): array {
24
		return ["ref","value"];
25
	}
26
27
}
28
29

Ubiquity/contents/validation/validators/comparison/LessThanOrEqualValidator.php 1 location

@@ 7-25 (lines=19) @@
4
5
use Ubiquity\contents\validation\validators\ValidatorHasNotNull;
6
7
class LessThanOrEqualValidator extends ValidatorHasNotNull {
8
	
9
	protected $ref;
10
	public function __construct(){
11
		$this->message="This value should be less or equal than `{ref}`";
12
	}
13
	public function validate($value) {
14
		parent::validate($value);
15
		return $value<=$this->ref;
16
	}
17
	/**
18
	 * {@inheritDoc}
19
	 * @see \Ubiquity\contents\validation\validators\Validator::getParameters()
20
	 */
21
	public function getParameters(): array {
22
		return ["ref","value"];
23
	}
24
25
}
26
27

Ubiquity/contents/validation/validators/comparison/RangeValidator.php 1 location

@@ 11-33 (lines=23) @@
8
 * @author jcheron <[email protected]>
9
 *
10
 */
11
class RangeValidator extends ValidatorHasNotNull {
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