Completed
Push — master ( 10806f...3a0750 )
by Jean-Christophe
01:35
created

IsBooleanValidator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 18
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A validate() 0 4 1
A getParameters() 0 3 1
1
<?php
2
3
namespace Ubiquity\contents\validation\validators\basic;
4
5
use Ubiquity\utils\base\UString;
6
use Ubiquity\contents\validation\validators\ValidatorHasNotNull;
7
8
class IsBooleanValidator extends ValidatorHasNotNull {
9
	
10
	public function __construct(){
11
		$this->message="This value should be a boolean";
12
	}
13
	public function validate($value) {
14
		parent::validate($value);
15
		return UString::isBooleanStr($value);
16
	}
17
	
18
	/**
19
	 * {@inheritDoc}
20
	 * @see \Ubiquity\contents\validation\validators\Validator::getParameters()
21
	 */
22
	public function getParameters(): array {
23
		return ["value"];
24
	}
25
}
26
27