forked from jeroendesloovere/vcard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathName.php
100 lines (81 loc) · 2.29 KB
/
Name.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
declare(strict_types=1);
namespace JeroenDesloovere\VCard\Property;
use JeroenDesloovere\VCard\Exception\PropertyException;
use JeroenDesloovere\VCard\Formatter\Property\NameFormatter;
use JeroenDesloovere\VCard\Formatter\Property\NodeFormatterInterface;
use JeroenDesloovere\VCard\Parser\Property\NameParser;
use JeroenDesloovere\VCard\Parser\Property\NodeParserInterface;
final class Name implements PropertyInterface, NodeInterface
{
/** @var null|string */
private $additional;
/** @var null|string */
private $firstName;
/** @var null|string */
private $lastName;
/** @var null|string */
private $prefix;
/** @var null|string */
private $suffix;
/**
* @param null|string $lastName
* @param null|string $firstName
* @param null|string $additional
* @param null|string $prefix
* @param null|string $suffix
* @throws PropertyException
*/
public function __construct(
?string $lastName = null,
?string $firstName = null,
?string $additional = null,
?string $prefix = null,
?string $suffix = null
) {
if ($lastName === null && $firstName === null && $additional === null && $prefix === null && $suffix === null) {
throw PropertyException::forEmptyProperty();
}
$this->lastName = $lastName;
$this->firstName = $firstName;
$this->additional = $additional;
$this->prefix = $prefix;
$this->suffix = $suffix;
}
public function getAdditional(): ?string
{
return $this->additional;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function getFormatter(): NodeFormatterInterface
{
return new NameFormatter($this);
}
public static function getParser(): NodeParserInterface
{
return new NameParser();
}
public function getLastName(): ?string
{
return $this->lastName;
}
public static function getNode(): string
{
return 'N';
}
public function getPrefix(): ?string
{
return $this->prefix;
}
public function getSuffix(): ?string
{
return $this->suffix;
}
public function isAllowedMultipleTimes(): bool
{
return false;
}
}