Total Complexity | 10 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
16 | class EmailType extends AbstractStringBasedType |
||
17 | { |
||
18 | /** |
||
19 | * Validate a email |
||
20 | * |
||
21 | * @param mixed $value |
||
22 | * |
||
23 | * @return bool |
||
24 | */ |
||
25 | 10 | protected function isValid($value): bool |
|
26 | { |
||
27 | 10 | return $value === null || (is_string($value) && filter_var($value, FILTER_VALIDATE_EMAIL)); |
|
28 | } |
||
29 | |||
30 | 6 | public function serialize($value) |
|
31 | { |
||
32 | 6 | if ($value === '') { |
|
33 | 1 | return null; |
|
34 | } |
||
35 | |||
36 | 5 | return parent::serialize($value); |
|
37 | } |
||
38 | |||
39 | 7 | public function parseValue($value) |
|
40 | { |
||
41 | 7 | if ($value === '') { |
|
42 | 1 | return null; |
|
43 | } |
||
44 | |||
45 | 6 | return parent::parseValue($value); |
|
46 | } |
||
47 | |||
48 | 5 | public function parseLiteral($ast, array $variables = null) |
|
55 | } |
||
56 | } |
||
57 |