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 integer $year The year to test |
||
33 | * @return boolean TRUE if the year is a leap year, otherwise FALSE |
||
34 | */ |
||
35 | public static function isLeapYear($year) |
||
39 | |||
40 | |||
41 | /** |
||
42 | * Return the number of days between two dates based on a 360 day calendar |
||
43 | * |
||
44 | * @param integer $startDay Day of month of the start date |
||
45 | * @param integer $startMonth Month of the start date |
||
46 | * @param integer $startYear Year of the start date |
||
47 | * @param integer $endDay Day of month of the start date |
||
48 | * @param integer $endMonth Month of the start date |
||
49 | * @param integer $endYear Year of the start date |
||
50 | * @param boolean $methodUS Whether to use the US method or the European method of calculation |
||
51 | * @return integer Number of days between the start date and the end date |
||
52 | */ |
||
53 | private static function dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, $methodUS) |
||
76 | |||
77 | |||
78 | /** |
||
79 | * getDateValue |
||
80 | * |
||
81 | * @param string $dateValue |
||
82 | * @return mixed Excel date/time serial value, or string if error |
||
83 | */ |
||
84 | public static function getDateValue($dateValue) |
||
102 | |||
103 | |||
104 | /** |
||
105 | * getTimeValue |
||
106 | * |
||
107 | * @param string $timeValue |
||
108 | * @return mixed Excel date/time serial value, or string if error |
||
109 | */ |
||
110 | private static function getTimeValue($timeValue) |
||
118 | |||
119 | |||
120 | private static function adjustDateByMonths($dateValue = 0, $adjustmentMonths = 0) |
||
145 | |||
146 | |||
147 | /** |
||
148 | * DATETIMENOW |
||
149 | * |
||
150 | * Returns the current date and time. |
||
151 | * The NOW function is useful when you need to display the current date and time on a worksheet or |
||
152 | * calculate a value based on the current date and time, and have that value updated each time you |
||
153 | * open the worksheet. |
||
154 | * |
||
155 | * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date |
||
156 | * and time format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. |
||
157 | * |
||
158 | * Excel Function: |
||
159 | * NOW() |
||
160 | * |
||
161 | * @access public |
||
162 | * @category Date/Time Functions |
||
163 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
||
164 | * depending on the value of the ReturnDateType flag |
||
165 | */ |
||
166 | public static function DATETIMENOW() |
||
186 | |||
187 | |||
188 | /** |
||
189 | * DATENOW |
||
190 | * |
||
191 | * Returns the current date. |
||
192 | * The NOW function is useful when you need to display the current date and time on a worksheet or |
||
193 | * calculate a value based on the current date and time, and have that value updated each time you |
||
194 | * open the worksheet. |
||
195 | * |
||
196 | * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date |
||
197 | * and time format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. |
||
198 | * |
||
199 | * Excel Function: |
||
200 | * TODAY() |
||
201 | * |
||
202 | * @access public |
||
203 | * @category Date/Time Functions |
||
204 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
||
205 | * depending on the value of the ReturnDateType flag |
||
206 | */ |
||
207 | public static function DATENOW() |
||
228 | |||
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 | * @access public |
||
246 | * @category Date/Time Functions |
||
247 | * @param integer $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 integer $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 integer $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 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
||
278 | * depending on the value of the ReturnDateType flag |
||
279 | */ |
||
280 | public static function DATE($year = 0, $month = 1, $day = 1) |
||
346 | |||
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 | * @access public |
||
360 | * @category Date/Time Functions |
||
361 | * @param integer $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 integer $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 integer $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 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
||
373 | * depending on the value of the ReturnDateType flag |
||
374 | */ |
||
375 | public static function TIME($hour = 0, $minute = 0, $second = 0) |
||
455 | |||
456 | |||
457 | /** |
||
458 | * DATEVALUE |
||
459 | * |
||
460 | * Returns a value that represents a particular date. |
||
461 | * Use DATEVALUE to convert a date represented by a text string to an Excel or PHP date/time stamp |
||
462 | * value. |
||
463 | * |
||
464 | * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date |
||
465 | * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. |
||
466 | * |
||
467 | * Excel Function: |
||
468 | * DATEVALUE(dateValue) |
||
469 | * |
||
470 | * @access public |
||
471 | * @category Date/Time Functions |
||
472 | * @param string $dateValue Text that represents a date in a Microsoft Excel date format. |
||
473 | * For example, "1/30/2008" or "30-Jan-2008" are text strings within |
||
474 | * quotation marks that represent dates. Using the default date |
||
475 | * system in Excel for Windows, date_text must represent a date from |
||
476 | * January 1, 1900, to December 31, 9999. Using the default date |
||
477 | * system in Excel for the Macintosh, date_text must represent a date |
||
478 | * from January 1, 1904, to December 31, 9999. DATEVALUE returns the |
||
479 | * #VALUE! error value if date_text is out of this range. |
||
480 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
||
481 | * depending on the value of the ReturnDateType flag |
||
482 | */ |
||
483 | public static function DATEVALUE($dateValue = 1) |
||
591 | |||
592 | |||
593 | /** |
||
594 | * TIMEVALUE |
||
595 | * |
||
596 | * Returns a value that represents a particular time. |
||
597 | * Use TIMEVALUE to convert a time represented by a text string to an Excel or PHP date/time stamp |
||
598 | * value. |
||
599 | * |
||
600 | * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the time |
||
601 | * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. |
||
602 | * |
||
603 | * Excel Function: |
||
604 | * TIMEVALUE(timeValue) |
||
605 | * |
||
606 | * @access public |
||
607 | * @category Date/Time Functions |
||
608 | * @param string $timeValue A text string that represents a time in any one of the Microsoft |
||
609 | * Excel time formats; for example, "6:45 PM" and "18:45" text strings |
||
610 | * within quotation marks that represent time. |
||
611 | * Date information in time_text is ignored. |
||
612 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
||
613 | * depending on the value of the ReturnDateType flag |
||
614 | */ |
||
615 | public static function TIMEVALUE($timeValue) |
||
652 | |||
653 | |||
654 | /** |
||
655 | * DATEDIF |
||
656 | * |
||
657 | * @param mixed $startDate Excel date serial value, PHP date/time stamp, PHP DateTime object |
||
658 | * or a standard date string |
||
659 | * @param mixed $endDate Excel date serial value, PHP date/time stamp, PHP DateTime object |
||
660 | * or a standard date string |
||
661 | * @param string $unit |
||
662 | * @return integer Interval between the dates |
||
663 | */ |
||
664 | public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D') |
||
757 | |||
758 | |||
759 | /** |
||
760 | * DAYS360 |
||
761 | * |
||
762 | * Returns the number of days between two dates based on a 360-day year (twelve 30-day months), |
||
763 | * which is used in some accounting calculations. Use this function to help compute payments if |
||
764 | * your accounting system is based on twelve 30-day months. |
||
765 | * |
||
766 | * Excel Function: |
||
767 | * DAYS360(startDate,endDate[,method]) |
||
768 | * |
||
769 | * @access public |
||
770 | * @category Date/Time Functions |
||
771 | * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), |
||
772 | * PHP DateTime object, or a standard date string |
||
773 | * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), |
||
774 | * PHP DateTime object, or a standard date string |
||
775 | * @param boolean $method US or European Method |
||
776 | * FALSE or omitted: U.S. (NASD) method. If the starting date is |
||
777 | * the last day of a month, it becomes equal to the 30th of the |
||
778 | * same month. If the ending date is the last day of a month and |
||
779 | * the starting date is earlier than the 30th of a month, the |
||
780 | * ending date becomes equal to the 1st of the next month; |
||
781 | * otherwise the ending date becomes equal to the 30th of the |
||
782 | * same month. |
||
783 | * TRUE: European method. Starting dates and ending dates that |
||
784 | * occur on the 31st of a month become equal to the 30th of the |
||
785 | * same month. |
||
786 | * @return integer Number of days between start date and end date |
||
787 | */ |
||
788 | public static function DAYS360($startDate = 0, $endDate = 0, $method = false) |
||
817 | |||
818 | |||
819 | /** |
||
820 | * YEARFRAC |
||
821 | * |
||
822 | * Calculates the fraction of the year represented by the number of whole days between two dates |
||
823 | * (the start_date and the end_date). |
||
824 | * Use the YEARFRAC worksheet function to identify the proportion of a whole year's benefits or |
||
825 | * obligations to assign to a specific term. |
||
826 | * |
||
827 | * Excel Function: |
||
828 | * YEARFRAC(startDate,endDate[,method]) |
||
829 | * |
||
830 | * @access public |
||
831 | * @category Date/Time Functions |
||
832 | * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), |
||
833 | * PHP DateTime object, or a standard date string |
||
834 | * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), |
||
835 | * PHP DateTime object, or a standard date string |
||
836 | * @param integer $method Method used for the calculation |
||
837 | * 0 or omitted US (NASD) 30/360 |
||
838 | * 1 Actual/actual |
||
839 | * 2 Actual/360 |
||
840 | * 3 Actual/365 |
||
841 | * 4 European 30/360 |
||
842 | * @return float fraction of the year |
||
843 | */ |
||
844 | public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0) |
||
915 | |||
916 | |||
917 | /** |
||
918 | * NETWORKDAYS |
||
919 | * |
||
920 | * Returns the number of whole working days between start_date and end_date. Working days |
||
921 | * exclude weekends and any dates identified in holidays. |
||
922 | * Use NETWORKDAYS to calculate employee benefits that accrue based on the number of days |
||
923 | * worked during a specific term. |
||
924 | * |
||
925 | * Excel Function: |
||
926 | * NETWORKDAYS(startDate,endDate[,holidays[,holiday[,...]]]) |
||
927 | * |
||
928 | * @access public |
||
929 | * @category Date/Time Functions |
||
930 | * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), |
||
931 | * PHP DateTime object, or a standard date string |
||
932 | * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), |
||
933 | * PHP DateTime object, or a standard date string |
||
934 | * @param mixed $holidays,... Optional series of Excel date serial value (float), PHP date |
||
935 | * timestamp (integer), PHP DateTime object, or a standard date |
||
936 | * strings that will be excluded from the working calendar, such |
||
937 | * as state and federal holidays and floating holidays. |
||
938 | * @return integer Interval between the dates |
||
939 | */ |
||
940 | public static function NETWORKDAYS($startDate, $endDate) |
||
1000 | |||
1001 | |||
1002 | /** |
||
1003 | * WORKDAY |
||
1004 | * |
||
1005 | * Returns the date that is the indicated number of working days before or after a date (the |
||
1006 | * starting date). Working days exclude weekends and any dates identified as holidays. |
||
1007 | * Use WORKDAY to exclude weekends or holidays when you calculate invoice due dates, expected |
||
1008 | * delivery times, or the number of days of work performed. |
||
1009 | * |
||
1010 | * Excel Function: |
||
1011 | * WORKDAY(startDate,endDays[,holidays[,holiday[,...]]]) |
||
1012 | * |
||
1013 | * @access public |
||
1014 | * @category Date/Time Functions |
||
1015 | * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), |
||
1016 | * PHP DateTime object, or a standard date string |
||
1017 | * @param integer $endDays The number of nonweekend and nonholiday days before or after |
||
1018 | * startDate. A positive value for days yields a future date; a |
||
1019 | * negative value yields a past date. |
||
1020 | * @param mixed $holidays,... Optional series of Excel date serial value (float), PHP date |
||
1021 | * timestamp (integer), PHP DateTime object, or a standard date |
||
1022 | * strings that will be excluded from the working calendar, such |
||
1023 | * as state and federal holidays and floating holidays. |
||
1024 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
||
1025 | * depending on the value of the ReturnDateType flag |
||
1026 | */ |
||
1027 | public static function WORKDAY($startDate, $endDays) |
||
1117 | |||
1118 | |||
1119 | /** |
||
1120 | * DAYOFMONTH |
||
1121 | * |
||
1122 | * Returns the day of the month, for a specified date. The day is given as an integer |
||
1123 | * ranging from 1 to 31. |
||
1124 | * |
||
1125 | * Excel Function: |
||
1126 | * DAY(dateValue) |
||
1127 | * |
||
1128 | * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
||
1129 | * PHP DateTime object, or a standard date string |
||
1130 | * @return int Day of the month |
||
1131 | */ |
||
1132 | public static function DAYOFMONTH($dateValue = 1) |
||
1151 | |||
1152 | |||
1153 | /** |
||
1154 | * DAYOFWEEK |
||
1155 | * |
||
1156 | * Returns the day of the week for a specified date. The day is given as an integer |
||
1157 | * ranging from 0 to 7 (dependent on the requested style). |
||
1158 | * |
||
1159 | * Excel Function: |
||
1160 | * WEEKDAY(dateValue[,style]) |
||
1161 | * |
||
1162 | * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
||
1163 | * PHP DateTime object, or a standard date string |
||
1164 | * @param int $style A number that determines the type of return value |
||
1165 | * 1 or omitted Numbers 1 (Sunday) through 7 (Saturday). |
||
1166 | * 2 Numbers 1 (Monday) through 7 (Sunday). |
||
1167 | * 3 Numbers 0 (Monday) through 6 (Sunday). |
||
1168 | * @return int Day of the week value |
||
1169 | */ |
||
1170 | public static function DAYOFWEEK($dateValue = 1, $style = 1) |
||
1224 | |||
1225 | |||
1226 | /** |
||
1227 | * WEEKOFYEAR |
||
1228 | * |
||
1229 | * Returns the week of the year for a specified date. |
||
1230 | * The WEEKNUM function considers the week containing January 1 to be the first week of the year. |
||
1231 | * However, there is a European standard that defines the first week as the one with the majority |
||
1232 | * of days (four or more) falling in the new year. This means that for years in which there are |
||
1233 | * three days or less in the first week of January, the WEEKNUM function returns week numbers |
||
1234 | * that are incorrect according to the European standard. |
||
1235 | * |
||
1236 | * Excel Function: |
||
1237 | * WEEKNUM(dateValue[,style]) |
||
1238 | * |
||
1239 | * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
||
1240 | * PHP DateTime object, or a standard date string |
||
1241 | * @param boolean $method Week begins on Sunday or Monday |
||
1242 | * 1 or omitted Week begins on Sunday. |
||
1243 | * 2 Week begins on Monday. |
||
1244 | * @return int Week Number |
||
1245 | */ |
||
1246 | public static function WEEKOFYEAR($dateValue = 1, $method = 1) |
||
1277 | |||
1278 | |||
1279 | /** |
||
1280 | * MONTHOFYEAR |
||
1281 | * |
||
1282 | * Returns the month of a date represented by a serial number. |
||
1283 | * The month is given as an integer, ranging from 1 (January) to 12 (December). |
||
1284 | * |
||
1285 | * Excel Function: |
||
1286 | * MONTH(dateValue) |
||
1287 | * |
||
1288 | * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
||
1289 | * PHP DateTime object, or a standard date string |
||
1290 | * @return int Month of the year |
||
1291 | */ |
||
1292 | View Code Duplication | public static function MONTHOFYEAR($dateValue = 1) |
|
1310 | |||
1311 | |||
1312 | /** |
||
1313 | * YEAR |
||
1314 | * |
||
1315 | * Returns the year corresponding to a date. |
||
1316 | * The year is returned as an integer in the range 1900-9999. |
||
1317 | * |
||
1318 | * Excel Function: |
||
1319 | * YEAR(dateValue) |
||
1320 | * |
||
1321 | * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
||
1322 | * PHP DateTime object, or a standard date string |
||
1323 | * @return int Year |
||
1324 | */ |
||
1325 | View Code Duplication | public static function YEAR($dateValue = 1) |
|
1342 | |||
1343 | |||
1344 | /** |
||
1345 | * HOUROFDAY |
||
1346 | * |
||
1347 | * Returns the hour of a time value. |
||
1348 | * The hour is given as an integer, ranging from 0 (12:00 A.M.) to 23 (11:00 P.M.). |
||
1349 | * |
||
1350 | * Excel Function: |
||
1351 | * HOUR(timeValue) |
||
1352 | * |
||
1353 | * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer), |
||
1354 | * PHP DateTime object, or a standard time string |
||
1355 | * @return int Hour |
||
1356 | */ |
||
1357 | View Code Duplication | public static function HOUROFDAY($timeValue = 0) |
|
1383 | |||
1384 | |||
1385 | /** |
||
1386 | * MINUTEOFHOUR |
||
1387 | * |
||
1388 | * Returns the minutes of a time value. |
||
1389 | * The minute is given as an integer, ranging from 0 to 59. |
||
1390 | * |
||
1391 | * Excel Function: |
||
1392 | * MINUTE(timeValue) |
||
1393 | * |
||
1394 | * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer), |
||
1395 | * PHP DateTime object, or a standard time string |
||
1396 | * @return int Minute |
||
1397 | */ |
||
1398 | View Code Duplication | public static function MINUTEOFHOUR($timeValue = 0) |
|
1424 | |||
1425 | |||
1426 | /** |
||
1427 | * SECONDOFMINUTE |
||
1428 | * |
||
1429 | * Returns the seconds of a time value. |
||
1430 | * The second is given as an integer in the range 0 (zero) to 59. |
||
1431 | * |
||
1432 | * Excel Function: |
||
1433 | * SECOND(timeValue) |
||
1434 | * |
||
1435 | * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer), |
||
1436 | * PHP DateTime object, or a standard time string |
||
1437 | * @return int Second |
||
1438 | */ |
||
1439 | View Code Duplication | public static function SECONDOFMINUTE($timeValue = 0) |
|
1465 | |||
1466 | |||
1467 | /** |
||
1468 | * EDATE |
||
1469 | * |
||
1470 | * Returns the serial number that represents the date that is the indicated number of months |
||
1471 | * before or after a specified date (the start_date). |
||
1472 | * Use EDATE to calculate maturity dates or due dates that fall on the same day of the month |
||
1473 | * as the date of issue. |
||
1474 | * |
||
1475 | * Excel Function: |
||
1476 | * EDATE(dateValue,adjustmentMonths) |
||
1477 | * |
||
1478 | * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
||
1479 | * PHP DateTime object, or a standard date string |
||
1480 | * @param int $adjustmentMonths The number of months before or after start_date. |
||
1481 | * A positive value for months yields a future date; |
||
1482 | * a negative value yields a past date. |
||
1483 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
||
1484 | * depending on the value of the ReturnDateType flag |
||
1485 | */ |
||
1486 | public static function EDATE($dateValue = 1, $adjustmentMonths = 0) |
||
1512 | |||
1513 | |||
1514 | /** |
||
1515 | * EOMONTH |
||
1516 | * |
||
1517 | * Returns the date value for the last day of the month that is the indicated number of months |
||
1518 | * before or after start_date. |
||
1519 | * Use EOMONTH to calculate maturity dates or due dates that fall on the last day of the month. |
||
1520 | * |
||
1521 | * Excel Function: |
||
1522 | * EOMONTH(dateValue,adjustmentMonths) |
||
1523 | * |
||
1524 | * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
||
1525 | * PHP DateTime object, or a standard date string |
||
1526 | * @param int $adjustmentMonths The number of months before or after start_date. |
||
1527 | * A positive value for months yields a future date; |
||
1528 | * a negative value yields a past date. |
||
1529 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
||
1530 | * depending on the value of the ReturnDateType flag |
||
1531 | */ |
||
1532 | public static function EOMONTH($dateValue = 1, $adjustmentMonths = 0) |
||
1561 | } |
||
1562 |
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.