1 | <?php |
||
7 | class Name |
||
8 | { |
||
9 | /** |
||
10 | * @var array the parts that make up this name |
||
11 | */ |
||
12 | protected $parts = []; |
||
13 | |||
14 | /** |
||
15 | * constructor takes the array of parts this name consists of |
||
16 | * |
||
17 | * @param array|null $parts |
||
18 | */ |
||
19 | public function __construct(array $parts = null) |
||
25 | |||
26 | /** |
||
27 | * @return string |
||
28 | */ |
||
29 | public function __toString(): string |
||
33 | |||
34 | /** |
||
35 | * set the parts this name consists of |
||
36 | * |
||
37 | * @param array $parts |
||
38 | * @return $this |
||
39 | */ |
||
40 | public function setParts(array $parts): Name |
||
46 | |||
47 | /** |
||
48 | * get the parts this name consists of |
||
49 | * |
||
50 | * @return array |
||
51 | */ |
||
52 | public function getParts(): array |
||
56 | |||
57 | /** |
||
58 | * @return array |
||
59 | */ |
||
60 | public function getAll(): array |
||
82 | |||
83 | /** |
||
84 | * get the first name |
||
85 | * |
||
86 | * @return string |
||
87 | */ |
||
88 | public function getFirstname(): string |
||
92 | |||
93 | /** |
||
94 | * get the last name |
||
95 | * |
||
96 | * @return string |
||
97 | */ |
||
98 | public function getLastname(): string |
||
102 | |||
103 | /** |
||
104 | * get the initials |
||
105 | * |
||
106 | * @return string |
||
107 | */ |
||
108 | public function getInitials(): string |
||
112 | |||
113 | /** |
||
114 | * get the suffix(es) |
||
115 | * |
||
116 | * @return string |
||
117 | */ |
||
118 | public function getSuffix(): string |
||
122 | |||
123 | /** |
||
124 | * get the salutation(s) |
||
125 | * |
||
126 | * @return string |
||
127 | */ |
||
128 | public function getSalutation(): string |
||
132 | |||
133 | /** |
||
134 | * get the nick name(s) |
||
135 | * |
||
136 | * @return string |
||
137 | */ |
||
138 | public function getNickname(): string |
||
142 | |||
143 | /** |
||
144 | * get the middle name(s) |
||
145 | * |
||
146 | * @return string |
||
147 | */ |
||
148 | public function getMiddlename(): string |
||
152 | |||
153 | /** |
||
154 | * helper method used by getters to extract and format relevant name parts |
||
155 | * |
||
156 | * @param string $type the part type to export |
||
157 | * @return string the exported parts |
||
158 | */ |
||
159 | protected function export($type): string |
||
171 | } |
||
172 |