EmailFieldValidator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace fieldwork\validators;
4
5
use Egulias\EmailValidator\EmailValidator;
6
7
class EmailFieldValidator extends RegexFieldValidator
8
{
9
10
    const PATT  = "/^.*@.*\\.[A-Z]{2,}$/i"; // This is a very simple version of the email validation regular expression which is only used client-side.
11
12
    private $validator;
13
14
    public function __construct ($error = "Enter a valid email address")
15
    {
16
        parent::__construct(self::PATT, $error);
17
        $this->validator = new EmailValidator();
18
    }
19
20
    public function isValid ($value)
21
    {
22
        return $this->validator->isValid($value);
23
    }
24
25
}