Passed
Push — master ( 0568ea...74fbac )
by Jean-Christophe
05:35
created

GreaterThanValidator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 90%

Importance

Changes 0
Metric Value
wmc 4
eloc 8
dl 0
loc 22
ccs 9
cts 10
cp 0.9
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A getParameters() 0 2 1
A validate() 0 6 2
1
<?php
2
3
namespace Ubiquity\contents\validation\validators\comparison;
4
5
use Ubiquity\contents\validation\validators\ValidatorHasNotNull;
6
7
class GreaterThanValidator extends ValidatorHasNotNull {
8
	protected $ref;
9
10 1
	public function __construct() {
11 1
		$this->message = "This value should be greater than `{ref}`";
12 1
	}
13
14 1
	public function validate($value) {
15 1
		parent::validate ( $value );
16 1
		if ($this->notNull !== false) {
17 1
			return $value > $this->ref;
18
		}
19
		return true;
20
	}
21
22
	/**
23
	 *
24
	 * {@inheritdoc}
25
	 * @see \Ubiquity\contents\validation\validators\Validator::getParameters()
26
	 */
27 1
	public function getParameters(): array {
28 1
		return [ "ref","value" ];
29
	}
30
}
31
32