forked from jeroendesloovere/vcard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmail.php
71 lines (57 loc) · 1.58 KB
/
Email.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
declare(strict_types=1);
namespace JeroenDesloovere\VCard\Property;
use JeroenDesloovere\VCard\Exception\PropertyException;
use JeroenDesloovere\VCard\Formatter\Property\EmailFormatter;
use JeroenDesloovere\VCard\Formatter\Property\NodeFormatterInterface;
use JeroenDesloovere\VCard\Parser\Property\EmailParser;
use JeroenDesloovere\VCard\Parser\Property\NodeParserInterface;
use JeroenDesloovere\VCard\Property\Parameter\Type;
final class Email implements PropertyInterface, NodeInterface
{
/** @var null|string */
private $email;
/** @var Type */
private $type;
/**
* @param null|string $email
* @param Type|null $type
* @throws PropertyException
*/
public function __construct(?string $email = null, Type $type = null)
{
if ($email === null && $type === null) {
throw PropertyException::forEmptyProperty();
}
$this->email = $email;
$this->type = $type ?? Type::home();
}
public function getFormatter(): NodeFormatterInterface
{
return new EmailFormatter($this);
}
public static function getNode(): string
{
return 'EMAIL';
}
public static function getParser(): NodeParserInterface
{
return new EmailParser();
}
public function isAllowedMultipleTimes(): bool
{
return true;
}
public function getEmail(): ?string
{
return $this->email;
}
public function getType(): Type
{
return $this->type;
}
public function setType(Type $type)
{
$this->type = $type;
}
}