Passed
Push — master ( f5da16...2e3bf1 )
by Jean-Christophe
12:28
created

EmailValidator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 4
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Ubiquity\contents\validation\validators\strings;
4
5
/**
6
 * Validates an email address
7
 * Usage @validator("email")
8
 *
9
 * @author jc
10
 * @version 1.0.0
11
 */
12
class EmailValidator extends RegexValidator {
13
14 3
	public function __construct() {
15 3
		$this->message = "{value} is not a valid email address";
16 3
		$this->ref = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/i";
17 3
		$this->match = true;
18 3
	}
19
20
	/**
21
	 *
22
	 * {@inheritdoc}
23
	 * @see \Ubiquity\contents\validation\validators\Validator::asUI()
24
	 */
25
	public function asUI(): array {
26
		return ['inputType'=>'email']+\array_merge_recursive(parent::asUI () , ['rules' => [ 'email' ]]);
27
	}
28
}
29
30