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 |
||
89 | |||
90 | /** |
||
91 | * get the given name (first name, middle names and initials) |
||
92 | * in the order they were entered while still applying normalisation |
||
93 | * |
||
94 | * @return string |
||
95 | */ |
||
96 | public function getGivenName(): string |
||
100 | |||
101 | /** |
||
102 | * get the given name followed by the last name (including any prefixes) |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | public function getFullName(): string |
||
110 | |||
111 | /** |
||
112 | * get the first name |
||
113 | * |
||
114 | * @return string |
||
115 | */ |
||
116 | public function getFirstname(): string |
||
120 | |||
121 | /** |
||
122 | * get the last name |
||
123 | * |
||
124 | * @param bool $pure |
||
125 | * @return string |
||
126 | */ |
||
127 | public function getLastname(bool $pure = false): string |
||
131 | |||
132 | /** |
||
133 | * get the last name prefix |
||
134 | * |
||
135 | * @return string |
||
136 | */ |
||
137 | public function getLastnamePrefix(): string |
||
141 | |||
142 | /** |
||
143 | * get the initials |
||
144 | * |
||
145 | * @return string |
||
146 | */ |
||
147 | public function getInitials(): string |
||
151 | |||
152 | /** |
||
153 | * get the suffix(es) |
||
154 | * |
||
155 | * @return string |
||
156 | */ |
||
157 | public function getSuffix(): string |
||
161 | |||
162 | /** |
||
163 | * get the salutation(s) |
||
164 | * |
||
165 | * @return string |
||
166 | */ |
||
167 | public function getSalutation(): string |
||
171 | |||
172 | /** |
||
173 | * get the nick name(s) |
||
174 | * |
||
175 | * @param bool $wrap |
||
176 | * @return string |
||
177 | */ |
||
178 | public function getNickname(bool $wrap = false): string |
||
186 | |||
187 | /** |
||
188 | * get the middle name(s) |
||
189 | * |
||
190 | * @return string |
||
191 | */ |
||
192 | public function getMiddlename(): string |
||
196 | |||
197 | /** |
||
198 | * get the company |
||
199 | * |
||
200 | * @return string |
||
201 | */ |
||
202 | public function getCompany(): string |
||
206 | |||
207 | /** |
||
208 | * get the extension |
||
209 | * |
||
210 | * @return string |
||
211 | */ |
||
212 | public function getExtension(): string |
||
216 | |||
217 | /** |
||
218 | * get the titles(s) |
||
219 | * |
||
220 | * @return string |
||
221 | */ |
||
222 | public function getTitle(): string |
||
226 | |||
227 | /** |
||
228 | * get an array with well formated names and their separators, |
||
229 | * where the keys are representing vCard properties |
||
230 | * see: https://tools.ietf.org/html/rfc6350#section-6.2.2 |
||
231 | * |
||
232 | * @return array |
||
233 | */ |
||
234 | public function getVCardArray(): array |
||
261 | |||
262 | /** |
||
263 | * helper method used by getters to extract and format relevant name parts |
||
264 | * |
||
265 | * @param string $type |
||
266 | * @param bool $strict |
||
267 | * @return string |
||
268 | */ |
||
269 | protected function export(string $type, bool $strict = false): string |
||
281 | |||
282 | /** |
||
283 | * helper method to check if a part is of the given type |
||
284 | * |
||
285 | * @param AbstractPart $part |
||
286 | * @param string $type |
||
287 | * @param bool $strict |
||
288 | * @return bool |
||
289 | */ |
||
290 | protected function isType(AbstractPart $part, string $type, bool $strict = false): bool |
||
300 | } |
||
301 |