1 | <?php |
||
8 | class Name |
||
9 | { |
||
10 | private const PARTS_NAMESPACE = 'TheIconic\NameParser\Part'; |
||
11 | |||
12 | /** |
||
13 | * @var array the parts that make up this name |
||
14 | */ |
||
15 | protected $parts = []; |
||
16 | |||
17 | /** |
||
18 | * constructor takes the array of parts this name consists of |
||
19 | * |
||
20 | * @param array|null $parts |
||
21 | */ |
||
22 | public function __construct(array $parts = null) |
||
28 | |||
29 | /** |
||
30 | * @return string |
||
31 | */ |
||
32 | public function __toString(): string |
||
36 | |||
37 | /** |
||
38 | * set the parts this name consists of |
||
39 | * |
||
40 | * @param array $parts |
||
41 | * @return $this |
||
42 | */ |
||
43 | public function setParts(array $parts): Name |
||
49 | |||
50 | /** |
||
51 | * get the parts this name consists of |
||
52 | * |
||
53 | * @return array |
||
54 | */ |
||
55 | public function getParts(): array |
||
59 | |||
60 | /** |
||
61 | * @param bool $format |
||
62 | * @return array |
||
63 | */ |
||
64 | public function getAll(bool $format = false): array |
||
86 | |||
87 | /** |
||
88 | * get the given name (first name, middle names and initials) |
||
89 | * in the order they were entered while still applying normalisation |
||
90 | * |
||
91 | * @return string |
||
92 | */ |
||
93 | public function getGivenName(): string |
||
97 | |||
98 | /** |
||
99 | * get the given name followed by the last name (including any prefixes) |
||
100 | * |
||
101 | * @return string |
||
102 | */ |
||
103 | public function getFullName(): string |
||
107 | |||
108 | /** |
||
109 | * get the first name |
||
110 | * |
||
111 | * @return string |
||
112 | */ |
||
113 | public function getFirstname(): string |
||
117 | |||
118 | /** |
||
119 | * get the last name |
||
120 | * |
||
121 | * @param bool $pure |
||
122 | * @return string |
||
123 | */ |
||
124 | public function getLastname(bool $pure = false): string |
||
128 | |||
129 | /** |
||
130 | * get the last name prefix |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | public function getLastnamePrefix(): string |
||
138 | |||
139 | /** |
||
140 | * get the initials |
||
141 | * |
||
142 | * @return string |
||
143 | */ |
||
144 | public function getInitials(): string |
||
148 | |||
149 | /** |
||
150 | * get the suffix(es) |
||
151 | * |
||
152 | * @return string |
||
153 | */ |
||
154 | public function getSuffix(): string |
||
158 | |||
159 | /** |
||
160 | * get the salutation(s) |
||
161 | * |
||
162 | * @return string |
||
163 | */ |
||
164 | public function getSalutation(): string |
||
168 | |||
169 | /** |
||
170 | * get the nick name(s) |
||
171 | * |
||
172 | * @param bool $wrap |
||
173 | * @return string |
||
174 | */ |
||
175 | public function getNickname(bool $wrap = false): string |
||
183 | |||
184 | /** |
||
185 | * get the middle name(s) |
||
186 | * |
||
187 | * @return string |
||
188 | */ |
||
189 | public function getMiddlename(): string |
||
193 | |||
194 | /** |
||
195 | * helper method used by getters to extract and format relevant name parts |
||
196 | * |
||
197 | * @param string $type |
||
198 | * @param bool $strict |
||
199 | * @return string |
||
200 | */ |
||
201 | protected function export(string $type, bool $strict = false): string |
||
213 | |||
214 | /** |
||
215 | * helper method to check if a part is of the given type |
||
216 | * |
||
217 | * @param AbstractPart $part |
||
218 | * @param string $type |
||
219 | * @param bool $strict |
||
220 | * @return bool |
||
221 | */ |
||
222 | protected function isType(AbstractPart $part, string $type, bool $strict = false): bool |
||
232 | } |
||
233 |