Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like DateTime often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use DateTime, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
27 | class DateTime |
||
28 | { |
||
29 | /** |
||
30 | * Identify if a year is a leap year or not. |
||
31 | * |
||
32 | * @param int $year The year to test |
||
33 | * |
||
34 | * @return bool TRUE if the year is a leap year, otherwise FALSE |
||
35 | */ |
||
36 | 20 | public static function isLeapYear($year) |
|
40 | |||
41 | /** |
||
42 | * Return the number of days between two dates based on a 360 day calendar. |
||
43 | * |
||
44 | * @param int $startDay Day of month of the start date |
||
45 | * @param int $startMonth Month of the start date |
||
46 | * @param int $startYear Year of the start date |
||
47 | * @param int $endDay Day of month of the start date |
||
48 | * @param int $endMonth Month of the start date |
||
49 | * @param int $endYear Year of the start date |
||
50 | * @param bool $methodUS Whether to use the US method or the European method of calculation |
||
51 | * |
||
52 | * @return int Number of days between the start date and the end date |
||
53 | */ |
||
54 | 68 | private static function dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, $methodUS) |
|
77 | |||
78 | /** |
||
79 | * getDateValue. |
||
80 | * |
||
81 | * @param string $dateValue |
||
82 | * |
||
83 | * @return mixed Excel date/time serial value, or string if error |
||
84 | */ |
||
85 | 382 | public static function getDateValue($dateValue) |
|
104 | |||
105 | /** |
||
106 | * getTimeValue. |
||
107 | * |
||
108 | * @param string $timeValue |
||
109 | * |
||
110 | * @return mixed Excel date/time serial value, or string if error |
||
111 | */ |
||
112 | 12 | private static function getTimeValue($timeValue) |
|
121 | |||
122 | 32 | private static function adjustDateByMonths($dateValue = 0, $adjustmentMonths = 0) |
|
148 | |||
149 | /** |
||
150 | * DATETIMENOW. |
||
151 | * |
||
152 | * Returns the current date and time. |
||
153 | * The NOW function is useful when you need to display the current date and time on a worksheet or |
||
154 | * calculate a value based on the current date and time, and have that value updated each time you |
||
155 | * open the worksheet. |
||
156 | * |
||
157 | * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date |
||
158 | * and time format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. |
||
159 | * |
||
160 | * Excel Function: |
||
161 | * NOW() |
||
162 | * |
||
163 | * @category Date/Time Functions |
||
164 | * |
||
165 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
||
166 | * depending on the value of the ReturnDateType flag |
||
167 | */ |
||
168 | public static function DATETIMENOW() |
||
188 | |||
189 | /** |
||
190 | * DATENOW. |
||
191 | * |
||
192 | * Returns the current date. |
||
193 | * The NOW function is useful when you need to display the current date and time on a worksheet or |
||
194 | * calculate a value based on the current date and time, and have that value updated each time you |
||
195 | * open the worksheet. |
||
196 | * |
||
197 | * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date |
||
198 | * and time format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. |
||
199 | * |
||
200 | * Excel Function: |
||
201 | * TODAY() |
||
202 | * |
||
203 | * @category Date/Time Functions |
||
204 | * |
||
205 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
||
206 | * depending on the value of the ReturnDateType flag |
||
207 | */ |
||
208 | 1 | public static function DATENOW() |
|
229 | |||
230 | /** |
||
231 | * DATE. |
||
232 | * |
||
233 | * The DATE function returns a value that represents a particular date. |
||
234 | * |
||
235 | * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date |
||
236 | * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. |
||
237 | * |
||
238 | * Excel Function: |
||
239 | * DATE(year,month,day) |
||
240 | * |
||
241 | * PhpSpreadsheet is a lot more forgiving than MS Excel when passing non numeric values to this function. |
||
242 | * A Month name or abbreviation (English only at this point) such as 'January' or 'Jan' will still be accepted, |
||
243 | * as will a day value with a suffix (e.g. '21st' rather than simply 21); again only English language. |
||
244 | * |
||
245 | * @category Date/Time Functions |
||
246 | * |
||
247 | * @param int $year The value of the year argument can include one to four digits. |
||
248 | * Excel interprets the year argument according to the configured |
||
249 | * date system: 1900 or 1904. |
||
250 | * If year is between 0 (zero) and 1899 (inclusive), Excel adds that |
||
251 | * value to 1900 to calculate the year. For example, DATE(108,1,2) |
||
252 | * returns January 2, 2008 (1900+108). |
||
253 | * If year is between 1900 and 9999 (inclusive), Excel uses that |
||
254 | * value as the year. For example, DATE(2008,1,2) returns January 2, |
||
255 | * 2008. |
||
256 | * If year is less than 0 or is 10000 or greater, Excel returns the |
||
257 | * #NUM! error value. |
||
258 | * @param int $month A positive or negative integer representing the month of the year |
||
259 | * from 1 to 12 (January to December). |
||
260 | * If month is greater than 12, month adds that number of months to |
||
261 | * the first month in the year specified. For example, DATE(2008,14,2) |
||
262 | * returns the serial number representing February 2, 2009. |
||
263 | * If month is less than 1, month subtracts the magnitude of that |
||
264 | * number of months, plus 1, from the first month in the year |
||
265 | * specified. For example, DATE(2008,-3,2) returns the serial number |
||
266 | * representing September 2, 2007. |
||
267 | * @param int $day A positive or negative integer representing the day of the month |
||
268 | * from 1 to 31. |
||
269 | * If day is greater than the number of days in the month specified, |
||
270 | * day adds that number of days to the first day in the month. For |
||
271 | * example, DATE(2008,1,35) returns the serial number representing |
||
272 | * February 4, 2008. |
||
273 | * If day is less than 1, day subtracts the magnitude that number of |
||
274 | * days, plus one, from the first day of the month specified. For |
||
275 | * example, DATE(2008,1,-15) returns the serial number representing |
||
276 | * December 16, 2007. |
||
277 | * |
||
278 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
||
279 | * depending on the value of the ReturnDateType flag |
||
280 | */ |
||
281 | 83 | public static function DATE($year = 0, $month = 1, $day = 1) |
|
347 | |||
348 | /** |
||
349 | * TIME. |
||
350 | * |
||
351 | * The TIME function returns a value that represents a particular time. |
||
352 | * |
||
353 | * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the time |
||
354 | * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. |
||
355 | * |
||
356 | * Excel Function: |
||
357 | * TIME(hour,minute,second) |
||
358 | * |
||
359 | * @category Date/Time Functions |
||
360 | * |
||
361 | * @param int $hour A number from 0 (zero) to 32767 representing the hour. |
||
362 | * Any value greater than 23 will be divided by 24 and the remainder |
||
363 | * will be treated as the hour value. For example, TIME(27,0,0) = |
||
364 | * TIME(3,0,0) = .125 or 3:00 AM. |
||
365 | * @param int $minute A number from 0 to 32767 representing the minute. |
||
366 | * Any value greater than 59 will be converted to hours and minutes. |
||
367 | * For example, TIME(0,750,0) = TIME(12,30,0) = .520833 or 12:30 PM. |
||
368 | * @param int $second A number from 0 to 32767 representing the second. |
||
369 | * Any value greater than 59 will be converted to hours, minutes, |
||
370 | * and seconds. For example, TIME(0,0,2000) = TIME(0,33,22) = .023148 |
||
371 | * or 12:33:20 AM |
||
372 | * |
||
373 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
||
374 | * depending on the value of the ReturnDateType flag |
||
375 | */ |
||
376 | 24 | public static function TIME($hour = 0, $minute = 0, $second = 0) |
|
458 | |||
459 | /** |
||
460 | * DATEVALUE. |
||
461 | * |
||
462 | * Returns a value that represents a particular date. |
||
463 | * Use DATEVALUE to convert a date represented by a text string to an Excel or PHP date/time stamp |
||
464 | * value. |
||
465 | * |
||
466 | * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date |
||
467 | * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. |
||
468 | * |
||
469 | * Excel Function: |
||
470 | * DATEVALUE(dateValue) |
||
471 | * |
||
472 | * @category Date/Time Functions |
||
473 | * |
||
474 | * @param string $dateValue Text that represents a date in a Microsoft Excel date format. |
||
475 | * For example, "1/30/2008" or "30-Jan-2008" are text strings within |
||
476 | * quotation marks that represent dates. Using the default date |
||
477 | * system in Excel for Windows, date_text must represent a date from |
||
478 | * January 1, 1900, to December 31, 9999. Using the default date |
||
479 | * system in Excel for the Macintosh, date_text must represent a date |
||
480 | * from January 1, 1904, to December 31, 9999. DATEVALUE returns the |
||
481 | * #VALUE! error value if date_text is out of this range. |
||
482 | * |
||
483 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
||
484 | * depending on the value of the ReturnDateType flag |
||
485 | */ |
||
486 | 423 | public static function DATEVALUE($dateValue = 1) |
|
594 | |||
595 | /** |
||
596 | * TIMEVALUE. |
||
597 | * |
||
598 | * Returns a value that represents a particular time. |
||
599 | * Use TIMEVALUE to convert a time represented by a text string to an Excel or PHP date/time stamp |
||
600 | * value. |
||
601 | * |
||
602 | * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the time |
||
603 | * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. |
||
604 | * |
||
605 | * Excel Function: |
||
606 | * TIMEVALUE(timeValue) |
||
607 | * |
||
608 | * @category Date/Time Functions |
||
609 | * |
||
610 | * @param string $timeValue A text string that represents a time in any one of the Microsoft |
||
611 | * Excel time formats; for example, "6:45 PM" and "18:45" text strings |
||
612 | * within quotation marks that represent time. |
||
613 | * Date information in time_text is ignored. |
||
614 | * |
||
615 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
||
616 | * depending on the value of the ReturnDateType flag |
||
617 | */ |
||
618 | 30 | public static function TIMEVALUE($timeValue) |
|
656 | |||
657 | /** |
||
658 | * DATEDIF. |
||
659 | * |
||
660 | * @param mixed $startDate Excel date serial value, PHP date/time stamp, PHP DateTime object |
||
661 | * or a standard date string |
||
662 | * @param mixed $endDate Excel date serial value, PHP date/time stamp, PHP DateTime object |
||
663 | * or a standard date string |
||
664 | * @param string $unit |
||
665 | * |
||
666 | * @return int Interval between the dates |
||
667 | */ |
||
668 | 150 | public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D') |
|
773 | |||
774 | /** |
||
775 | * DAYS360. |
||
776 | * |
||
777 | * Returns the number of days between two dates based on a 360-day year (twelve 30-day months), |
||
778 | * which is used in some accounting calculations. Use this function to help compute payments if |
||
779 | * your accounting system is based on twelve 30-day months. |
||
780 | * |
||
781 | * Excel Function: |
||
782 | * DAYS360(startDate,endDate[,method]) |
||
783 | * |
||
784 | * @category Date/Time Functions |
||
785 | * |
||
786 | * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), |
||
787 | * PHP DateTime object, or a standard date string |
||
788 | * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), |
||
789 | * PHP DateTime object, or a standard date string |
||
790 | * @param bool $method US or European Method |
||
791 | * FALSE or omitted: U.S. (NASD) method. If the starting date is |
||
792 | * the last day of a month, it becomes equal to the 30th of the |
||
793 | * same month. If the ending date is the last day of a month and |
||
794 | * the starting date is earlier than the 30th of a month, the |
||
795 | * ending date becomes equal to the 1st of the next month; |
||
796 | * otherwise the ending date becomes equal to the 30th of the |
||
797 | * same month. |
||
798 | * TRUE: European method. Starting dates and ending dates that |
||
799 | * occur on the 31st of a month become equal to the 30th of the |
||
800 | * same month. |
||
801 | * |
||
802 | * @return int Number of days between start date and end date |
||
803 | */ |
||
804 | 72 | public static function DAYS360($startDate = 0, $endDate = 0, $method = false) |
|
833 | |||
834 | /** |
||
835 | * YEARFRAC. |
||
836 | * |
||
837 | * Calculates the fraction of the year represented by the number of whole days between two dates |
||
838 | * (the start_date and the end_date). |
||
839 | * Use the YEARFRAC worksheet function to identify the proportion of a whole year's benefits or |
||
840 | * obligations to assign to a specific term. |
||
841 | * |
||
842 | * Excel Function: |
||
843 | * YEARFRAC(startDate,endDate[,method]) |
||
844 | * |
||
845 | * @category Date/Time Functions |
||
846 | * |
||
847 | * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), |
||
848 | * PHP DateTime object, or a standard date string |
||
849 | * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), |
||
850 | * PHP DateTime object, or a standard date string |
||
851 | * @param int $method Method used for the calculation |
||
852 | * 0 or omitted US (NASD) 30/360 |
||
853 | * 1 Actual/actual |
||
854 | * 2 Actual/360 |
||
855 | * 3 Actual/365 |
||
856 | * 4 European 30/360 |
||
857 | * |
||
858 | * @return float fraction of the year |
||
859 | */ |
||
860 | 89 | public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0) |
|
933 | |||
934 | /** |
||
935 | * NETWORKDAYS. |
||
936 | * |
||
937 | * Returns the number of whole working days between start_date and end_date. Working days |
||
938 | * exclude weekends and any dates identified in holidays. |
||
939 | * Use NETWORKDAYS to calculate employee benefits that accrue based on the number of days |
||
940 | * worked during a specific term. |
||
941 | * |
||
942 | * Excel Function: |
||
943 | * NETWORKDAYS(startDate,endDate[,holidays[,holiday[,...]]]) |
||
944 | * |
||
945 | * @category Date/Time Functions |
||
946 | * |
||
947 | * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), |
||
948 | * PHP DateTime object, or a standard date string |
||
949 | * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), |
||
950 | * PHP DateTime object, or a standard date string |
||
951 | * |
||
952 | * @return int Interval between the dates |
||
953 | */ |
||
954 | 18 | public static function NETWORKDAYS($startDate, $endDate, ...$dateArgs) |
|
1013 | |||
1014 | /** |
||
1015 | * WORKDAY. |
||
1016 | * |
||
1017 | * Returns the date that is the indicated number of working days before or after a date (the |
||
1018 | * starting date). Working days exclude weekends and any dates identified as holidays. |
||
1019 | * Use WORKDAY to exclude weekends or holidays when you calculate invoice due dates, expected |
||
1020 | * delivery times, or the number of days of work performed. |
||
1021 | * |
||
1022 | * Excel Function: |
||
1023 | * WORKDAY(startDate,endDays[,holidays[,holiday[,...]]]) |
||
1024 | * |
||
1025 | * @category Date/Time Functions |
||
1026 | * |
||
1027 | * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), |
||
1028 | * PHP DateTime object, or a standard date string |
||
1029 | * @param int $endDays The number of nonweekend and nonholiday days before or after |
||
1030 | * startDate. A positive value for days yields a future date; a |
||
1031 | * negative value yields a past date. |
||
1032 | * |
||
1033 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
||
1034 | * depending on the value of the ReturnDateType flag |
||
1035 | */ |
||
1036 | 13 | public static function WORKDAY($startDate, $endDays, ...$dateArgs) |
|
1124 | |||
1125 | /** |
||
1126 | * DAYOFMONTH. |
||
1127 | * |
||
1128 | * Returns the day of the month, for a specified date. The day is given as an integer |
||
1129 | * ranging from 1 to 31. |
||
1130 | * |
||
1131 | * Excel Function: |
||
1132 | * DAY(dateValue) |
||
1133 | * |
||
1134 | * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
||
1135 | * PHP DateTime object, or a standard date string |
||
1136 | * |
||
1137 | * @return int Day of the month |
||
1138 | */ |
||
1139 | 17 | public static function DAYOFMONTH($dateValue = 1) |
|
1158 | |||
1159 | /** |
||
1160 | * WEEKDAY. |
||
1161 | * |
||
1162 | * Returns the day of the week for a specified date. The day is given as an integer |
||
1163 | * ranging from 0 to 7 (dependent on the requested style). |
||
1164 | * |
||
1165 | * Excel Function: |
||
1166 | * WEEKDAY(dateValue[,style]) |
||
1167 | * |
||
1168 | * @param int $dateValue Excel date serial value (float), PHP date timestamp (integer), |
||
1169 | * PHP DateTime object, or a standard date string |
||
1170 | * @param int $style A number that determines the type of return value |
||
1171 | * 1 or omitted Numbers 1 (Sunday) through 7 (Saturday). |
||
1172 | * 2 Numbers 1 (Monday) through 7 (Sunday). |
||
1173 | * 3 Numbers 0 (Monday) through 6 (Sunday). |
||
1174 | * |
||
1175 | * @return int Day of the week value |
||
1176 | */ |
||
1177 | 57 | public static function WEEKDAY($dateValue = 1, $style = 1) |
|
1231 | |||
1232 | /** |
||
1233 | * WEEKNUM. |
||
1234 | * |
||
1235 | * Returns the week of the year for a specified date. |
||
1236 | * The WEEKNUM function considers the week containing January 1 to be the first week of the year. |
||
1237 | * However, there is a European standard that defines the first week as the one with the majority |
||
1238 | * of days (four or more) falling in the new year. This means that for years in which there are |
||
1239 | * three days or less in the first week of January, the WEEKNUM function returns week numbers |
||
1240 | * that are incorrect according to the European standard. |
||
1241 | * |
||
1242 | * Excel Function: |
||
1243 | * WEEKNUM(dateValue[,style]) |
||
1244 | * |
||
1245 | * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
||
1246 | * PHP DateTime object, or a standard date string |
||
1247 | * @param int $method Week begins on Sunday or Monday |
||
1248 | * 1 or omitted Week begins on Sunday. |
||
1249 | * 2 Week begins on Monday. |
||
1250 | * |
||
1251 | * @return int Week Number |
||
1252 | */ |
||
1253 | 15 | public static function WEEKNUM($dateValue = 1, $method = 1) |
|
1288 | |||
1289 | /** |
||
1290 | * MONTHOFYEAR. |
||
1291 | * |
||
1292 | * Returns the month of a date represented by a serial number. |
||
1293 | * The month is given as an integer, ranging from 1 (January) to 12 (December). |
||
1294 | * |
||
1295 | * Excel Function: |
||
1296 | * MONTH(dateValue) |
||
1297 | * |
||
1298 | * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
||
1299 | * PHP DateTime object, or a standard date string |
||
1300 | * |
||
1301 | * @return int Month of the year |
||
1302 | */ |
||
1303 | 21 | View Code Duplication | public static function MONTHOFYEAR($dateValue = 1) |
1321 | |||
1322 | /** |
||
1323 | * YEAR. |
||
1324 | * |
||
1325 | * Returns the year corresponding to a date. |
||
1326 | * The year is returned as an integer in the range 1900-9999. |
||
1327 | * |
||
1328 | * Excel Function: |
||
1329 | * YEAR(dateValue) |
||
1330 | * |
||
1331 | * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
||
1332 | * PHP DateTime object, or a standard date string |
||
1333 | * |
||
1334 | * @return int Year |
||
1335 | */ |
||
1336 | 33 | View Code Duplication | public static function YEAR($dateValue = 1) |
1353 | |||
1354 | /** |
||
1355 | * HOUROFDAY. |
||
1356 | * |
||
1357 | * Returns the hour of a time value. |
||
1358 | * The hour is given as an integer, ranging from 0 (12:00 A.M.) to 23 (11:00 P.M.). |
||
1359 | * |
||
1360 | * Excel Function: |
||
1361 | * HOUR(timeValue) |
||
1362 | * |
||
1363 | * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer), |
||
1364 | * PHP DateTime object, or a standard time string |
||
1365 | * |
||
1366 | * @return int Hour |
||
1367 | */ |
||
1368 | 12 | View Code Duplication | public static function HOUROFDAY($timeValue = 0) |
1394 | |||
1395 | /** |
||
1396 | * MINUTE. |
||
1397 | * |
||
1398 | * Returns the minutes of a time value. |
||
1399 | * The minute is given as an integer, ranging from 0 to 59. |
||
1400 | * |
||
1401 | * Excel Function: |
||
1402 | * MINUTE(timeValue) |
||
1403 | * |
||
1404 | * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer), |
||
1405 | * PHP DateTime object, or a standard time string |
||
1406 | * |
||
1407 | * @return int Minute |
||
1408 | */ |
||
1409 | 12 | View Code Duplication | public static function MINUTE($timeValue = 0) |
1435 | |||
1436 | /** |
||
1437 | * SECOND. |
||
1438 | * |
||
1439 | * Returns the seconds of a time value. |
||
1440 | * The second is given as an integer in the range 0 (zero) to 59. |
||
1441 | * |
||
1442 | * Excel Function: |
||
1443 | * SECOND(timeValue) |
||
1444 | * |
||
1445 | * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer), |
||
1446 | * PHP DateTime object, or a standard time string |
||
1447 | * |
||
1448 | * @return int Second |
||
1449 | */ |
||
1450 | 12 | View Code Duplication | public static function SECOND($timeValue = 0) |
1476 | |||
1477 | /** |
||
1478 | * EDATE. |
||
1479 | * |
||
1480 | * Returns the serial number that represents the date that is the indicated number of months |
||
1481 | * before or after a specified date (the start_date). |
||
1482 | * Use EDATE to calculate maturity dates or due dates that fall on the same day of the month |
||
1483 | * as the date of issue. |
||
1484 | * |
||
1485 | * Excel Function: |
||
1486 | * EDATE(dateValue,adjustmentMonths) |
||
1487 | * |
||
1488 | * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
||
1489 | * PHP DateTime object, or a standard date string |
||
1490 | * @param int $adjustmentMonths The number of months before or after start_date. |
||
1491 | * A positive value for months yields a future date; |
||
1492 | * a negative value yields a past date. |
||
1493 | * |
||
1494 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
||
1495 | * depending on the value of the ReturnDateType flag |
||
1496 | */ |
||
1497 | 17 | public static function EDATE($dateValue = 1, $adjustmentMonths = 0) |
|
1523 | |||
1524 | /** |
||
1525 | * EOMONTH. |
||
1526 | * |
||
1527 | * Returns the date value for the last day of the month that is the indicated number of months |
||
1528 | * before or after start_date. |
||
1529 | * Use EOMONTH to calculate maturity dates or due dates that fall on the last day of the month. |
||
1530 | * |
||
1531 | * Excel Function: |
||
1532 | * EOMONTH(dateValue,adjustmentMonths) |
||
1533 | * |
||
1534 | * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
||
1535 | * PHP DateTime object, or a standard date string |
||
1536 | * @param int $adjustmentMonths The number of months before or after start_date. |
||
1537 | * A positive value for months yields a future date; |
||
1538 | * a negative value yields a past date. |
||
1539 | * |
||
1540 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
||
1541 | * depending on the value of the ReturnDateType flag |
||
1542 | */ |
||
1543 | 19 | public static function EOMONTH($dateValue = 1, $adjustmentMonths = 0) |
|
1572 | } |
||
1573 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.