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

ValidatorHasNotNull   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 12
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 8 5
1
<?php
2
3
namespace Ubiquity\contents\validation\validators;
4
5
use Ubiquity\exceptions\ValidatorException;
6
use Ubiquity\utils\base\UString;
7
8
abstract class ValidatorHasNotNull extends Validator implements HasNotNullInterface{
9
	protected $notNull;
10
	
11
	public function validate($value) {
12
		if ($this->notNull!==false && (null === $value || '' === $value)) {
13
			return;
14
		}
15
		if (!UString::isValid($value)) {
16
			throw new ValidatorException('This value can not be converted to string');
17
		}
18
	}
19
}
20
21