Completed
Push — master ( 94ddbb...e5219e )
by Jean-Christophe
04:25
created

ValidatorHasNotNull::validate()   A

Complexity

Conditions 5
Paths 3

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 5.2

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
ccs 4
cts 5
cp 0.8
rs 9.6111
c 0
b 0
f 0
cc 5
nc 3
nop 1
crap 5.2
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 2
	public function validate($value) {
12 2
		if ($this->notNull!==false && (null === $value || '' === $value)) {
13 2
			return;
14
		}
15 1
		if (!UString::isValid($value)) {
16
			throw new ValidatorException('This value can not be converted to string');
17
		}
18 1
	}
19
}
20
21