1 | <?php |
||
13 | trait Formatter |
||
14 | { |
||
15 | /** |
||
16 | * Accepts the same format as the date() function. |
||
17 | * |
||
18 | * @see date(), \DateTime |
||
19 | * |
||
20 | * @param $format |
||
21 | * |
||
22 | * @return string |
||
23 | */ |
||
24 | 5 | public function format(string $format) |
|
41 | |||
42 | /** |
||
43 | * Return the value of the format character. |
||
44 | * |
||
45 | * @param string $name of the field |
||
46 | * @param bool $skip |
||
47 | * |
||
48 | * @return string |
||
49 | */ |
||
50 | 5 | protected function getValueOfFormatCharacter(string $name, bool &$skip = false): string |
|
62 | |||
63 | /** |
||
64 | * (01-30) Day of the month, 2 digits with leading zeros. |
||
65 | * |
||
66 | * @return string |
||
67 | */ |
||
68 | 4 | public function getDayTwoDigit(): string |
|
74 | |||
75 | /** |
||
76 | * (ሰኞ-እሑድ) A full textual representation of the day of the week. |
||
77 | * |
||
78 | * return string |
||
79 | */ |
||
80 | 4 | public function getTextualDay(): string |
|
84 | |||
85 | /** |
||
86 | * (ሰኞ-እሑ) A textual representation of a day, two letters. |
||
87 | * |
||
88 | * return string |
||
89 | */ |
||
90 | 2 | public function getTextualDayShort(): string |
|
96 | |||
97 | /** |
||
98 | * (መስከረም-ጳጉሜን) A full textual representation of a month. |
||
99 | * |
||
100 | * @return string |
||
101 | */ |
||
102 | 4 | public function getTextualMonth(): string |
|
106 | |||
107 | /** |
||
108 | * (መስ - ጳጉ) A short textual representation of a month, two letters. |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | 3 | public function getTextualMonthShort(): string |
|
118 | |||
119 | /** |
||
120 | * (01-13) Numeric representation of a month, with leading zeros. |
||
121 | * |
||
122 | * @return string |
||
123 | */ |
||
124 | 2 | public function getMonthTwoDigit(): string |
|
130 | |||
131 | /** |
||
132 | * (1 or 0) Whether it's a leap year. |
||
133 | * |
||
134 | * @return string |
||
135 | */ |
||
136 | 1 | public function getLeapYearString(): string |
|
140 | |||
141 | /** |
||
142 | * returns 97 for the year 1997. |
||
143 | * |
||
144 | * @return string |
||
145 | */ |
||
146 | 1 | public function getYearShort(): string |
|
152 | |||
153 | /** |
||
154 | * Return the amharic equivalent of AM & PM. |
||
155 | * |
||
156 | * (እኩለ፡ሌሊት-ምሽት) |
||
157 | * |
||
158 | * It suppose to format 'Ante meridiem' and 'Post meridiem' |
||
159 | * But we Ethiopians classify the day in <b>ten</b> parts |
||
160 | * and we don't have Uppercase and Lowercase letters |
||
161 | * |
||
162 | * @link http://web.archive.org/web/20140331152859/http://ethiopic.org/Calendars/ |
||
163 | * |
||
164 | * @return string |
||
165 | */ |
||
166 | 4 | public function getTimeOfDay(): string |
|
189 | |||
190 | /** |
||
191 | * 1 (for 'ልደታ'), 2 (for አባ፡ጉባ), ... 30 (for ማርቆስ). |
||
192 | * |
||
193 | * @return string the ethiopian orthodox day name |
||
194 | */ |
||
195 | 2 | public function getOrthodoxDay(): string |
|
199 | |||
200 | /** |
||
201 | * ዓ/ም or ዓ/ዓ. |
||
202 | * |
||
203 | * @return string |
||
204 | */ |
||
205 | 3 | public function getTextualEra(): string |
|
209 | |||
210 | /** |
||
211 | * ማቴዎስ, ማርቆስ, ሉቃስ or ዮሐንስ. |
||
212 | * |
||
213 | * @return string the ethiopian orthodox year name |
||
214 | */ |
||
215 | 3 | public function getOrthodoxYear(): string |
|
219 | |||
220 | /** |
||
221 | * Return the year in geez number. |
||
222 | * |
||
223 | * @throws \Geezify\Exception\NotAnIntegerArgumentException |
||
224 | * |
||
225 | * @return string |
||
226 | */ |
||
227 | 2 | public function getYearInGeez(): string |
|
231 | |||
232 | /** |
||
233 | * Return the day in geez number. |
||
234 | * |
||
235 | * @return string |
||
236 | */ |
||
237 | 2 | public function getDayInGeez(): string |
|
241 | |||
242 | /** |
||
243 | * Return an empty string. |
||
244 | * |
||
245 | * @return string |
||
246 | */ |
||
247 | 4 | public function getTimeZoneString(): string |
|
253 | |||
254 | /** |
||
255 | * Return `ኛው` rather than st,nd,rd, and th. |
||
256 | * |
||
257 | * @return string |
||
258 | */ |
||
259 | 2 | public function getOrdinalSuffix(): string |
|
263 | |||
264 | /** |
||
265 | * RFC 2822 formatted date. |
||
266 | * |
||
267 | * @return string |
||
268 | */ |
||
269 | 1 | public function getFormattedDate(): string |
|
273 | |||
274 | /** |
||
275 | * @param string $name |
||
276 | * |
||
277 | * @return bool |
||
278 | */ |
||
279 | 5 | protected function isOverrideFormatCharacter($name): bool |
|
283 | |||
284 | /** |
||
285 | * @param string $name |
||
286 | * @param bool $skip |
||
287 | * |
||
288 | * @return string|false |
||
289 | */ |
||
290 | 5 | protected function shouldWeSkip($name, &$skip) |
|
298 | |||
299 | /** |
||
300 | * @param $name |
||
301 | * @param $skip |
||
302 | * |
||
303 | * @return bool |
||
304 | */ |
||
305 | 5 | protected function shouldWeSkip4Real($name, &$skip): bool |
|
309 | |||
310 | /** |
||
311 | * @param $name |
||
312 | * @param $skip |
||
313 | * |
||
314 | * @return string |
||
315 | */ |
||
316 | 1 | protected function skipCharacter($name, &$skip): string |
|
330 | |||
331 | /** |
||
332 | * @param $name |
||
333 | * |
||
334 | * @return bool |
||
335 | */ |
||
336 | 5 | protected function isSkipCharacter($name): bool |
|
340 | } |
||
341 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: