Total Complexity | 10 |
Total Lines | 57 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
12 | final class Email implements PropertyInterface, NodeInterface |
||
13 | { |
||
14 | /** |
||
15 | * @var null|string |
||
16 | */ |
||
17 | private $email; |
||
18 | |||
19 | /** |
||
20 | * @var Type |
||
21 | */ |
||
22 | private $type; |
||
23 | |||
24 | public function __construct( |
||
25 | ?string $email = null, |
||
26 | Type $type = null |
||
27 | ) { |
||
28 | if ($email === null && $type === null) { |
||
29 | throw PropertyException::forEmptyProperty(); |
||
30 | } |
||
31 | |||
32 | $this->email = $email; |
||
33 | $this->type = $type ?? Type::home(); |
||
34 | } |
||
35 | |||
36 | public function getFormatter(): NodeFormatterInterface |
||
37 | { |
||
38 | return new EmailFormatter($this); |
||
39 | } |
||
40 | |||
41 | public static function getNode(): string |
||
42 | { |
||
43 | return 'EMAIL'; |
||
44 | } |
||
45 | |||
46 | public static function getParser(): NodeParserInterface |
||
47 | { |
||
48 | return new EmailParser(); |
||
49 | } |
||
50 | |||
51 | public function isAllowedMultipleTimes(): bool |
||
52 | { |
||
53 | return true; |
||
54 | } |
||
55 | |||
56 | public function getEmail(): ?string |
||
57 | { |
||
58 | return $this->email; |
||
59 | } |
||
60 | |||
61 | public function getType(): Type |
||
64 | } |
||
65 | |||
66 | public function setType(Type $type) |
||
69 | } |
||
70 | } |
||
71 |