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 |
||
105 | |||
106 | /** |
||
107 | * get the given name followed by the last name (including any prefixes) |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | public function getFullName(): string |
||
115 | |||
116 | /** |
||
117 | * get the first name |
||
118 | * |
||
119 | * @return string |
||
120 | */ |
||
121 | public function getFirstname(): string |
||
125 | |||
126 | /** |
||
127 | * get the last name |
||
128 | * |
||
129 | * @param bool $pure |
||
130 | * @return string |
||
131 | */ |
||
132 | public function getLastname(bool $pure = false): string |
||
136 | |||
137 | /** |
||
138 | * get the last name prefix |
||
139 | * |
||
140 | * @return string |
||
141 | */ |
||
142 | public function getLastnamePrefix(): string |
||
146 | |||
147 | /** |
||
148 | * get the initials |
||
149 | * |
||
150 | * @return string |
||
151 | */ |
||
152 | public function getInitials(): string |
||
156 | |||
157 | /** |
||
158 | * get the suffix(es) |
||
159 | * |
||
160 | * @return string |
||
161 | */ |
||
162 | public function getSuffix(): string |
||
166 | |||
167 | /** |
||
168 | * get the salutation(s) |
||
169 | * |
||
170 | * @return string |
||
171 | */ |
||
172 | public function getSalutation(): string |
||
176 | |||
177 | /** |
||
178 | * get the nick name(s) |
||
179 | * |
||
180 | * @param bool $wrap |
||
181 | * @return string |
||
182 | */ |
||
183 | public function getNickname(bool $wrap = false): string |
||
191 | |||
192 | /** |
||
193 | * get the middle name(s) |
||
194 | * |
||
195 | * @return string |
||
196 | */ |
||
197 | public function getMiddlename(): string |
||
201 | |||
202 | /** |
||
203 | * helper method used by getters to extract and format relevant name parts |
||
204 | * |
||
205 | * @param string $type |
||
206 | * @param bool $strict |
||
207 | * @return string |
||
208 | */ |
||
209 | protected function export(string $type, bool $strict = false): string |
||
221 | |||
222 | /** |
||
223 | * helper method to check if a part is of the given type |
||
224 | * |
||
225 | * @param AbstractPart $part |
||
226 | * @param string $type |
||
227 | * @param bool $strict |
||
228 | * @return bool |
||
229 | */ |
||
230 | protected function isType(AbstractPart $part, string $type, bool $strict = false): bool |
||
240 | } |
||
241 |