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

EmailValidator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 71.43%

Importance

Changes 0
Metric Value
wmc 2
eloc 5
c 0
b 0
f 0
dl 0
loc 15
ccs 5
cts 7
cp 0.7143
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A asUI() 0 2 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