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 |
||
8 | class DateTime |
||
9 | { |
||
10 | /** |
||
11 | * Identify if a year is a leap year or not. |
||
12 | * |
||
13 | * @param int $year The year to test |
||
14 | * |
||
15 | * @return bool TRUE if the year is a leap year, otherwise FALSE |
||
16 | */ |
||
17 | 20 | public static function isLeapYear($year) |
|
21 | |||
22 | /** |
||
23 | * Return the number of days between two dates based on a 360 day calendar. |
||
24 | * |
||
25 | * @param int $startDay Day of month of the start date |
||
26 | * @param int $startMonth Month of the start date |
||
27 | * @param int $startYear Year of the start date |
||
28 | * @param int $endDay Day of month of the start date |
||
29 | * @param int $endMonth Month of the start date |
||
30 | * @param int $endYear Year of the start date |
||
31 | * @param bool $methodUS Whether to use the US method or the European method of calculation |
||
32 | * |
||
33 | * @return int Number of days between the start date and the end date |
||
34 | */ |
||
35 | 68 | private static function dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, $methodUS) |
|
58 | |||
59 | /** |
||
60 | * getDateValue. |
||
61 | * |
||
62 | * @param string $dateValue |
||
63 | * |
||
64 | * @return mixed Excel date/time serial value, or string if error |
||
65 | */ |
||
66 | 382 | public static function getDateValue($dateValue) |
|
85 | |||
86 | /** |
||
87 | * getTimeValue. |
||
88 | * |
||
89 | * @param string $timeValue |
||
90 | * |
||
91 | * @return mixed Excel date/time serial value, or string if error |
||
92 | */ |
||
93 | 12 | private static function getTimeValue($timeValue) |
|
102 | |||
103 | 32 | private static function adjustDateByMonths($dateValue = 0, $adjustmentMonths = 0) |
|
129 | |||
130 | /** |
||
131 | * DATETIMENOW. |
||
132 | * |
||
133 | * Returns the current date and time. |
||
134 | * The NOW function is useful when you need to display the current date and time on a worksheet or |
||
135 | * calculate a value based on the current date and time, and have that value updated each time you |
||
136 | * open the worksheet. |
||
137 | * |
||
138 | * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date |
||
139 | * and time format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. |
||
140 | * |
||
141 | * Excel Function: |
||
142 | * NOW() |
||
143 | * |
||
144 | * @category Date/Time Functions |
||
145 | * |
||
146 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
||
147 | * depending on the value of the ReturnDateType flag |
||
148 | */ |
||
149 | public static function DATETIMENOW() |
||
172 | |||
173 | /** |
||
174 | * DATENOW. |
||
175 | * |
||
176 | * Returns the current date. |
||
177 | * The NOW function is useful when you need to display the current date and time on a worksheet or |
||
178 | * calculate a value based on the current date and time, and have that value updated each time you |
||
179 | * open the worksheet. |
||
180 | * |
||
181 | * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date |
||
182 | * and time format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. |
||
183 | * |
||
184 | * Excel Function: |
||
185 | * TODAY() |
||
186 | * |
||
187 | * @category Date/Time Functions |
||
188 | * |
||
189 | 1 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
|
190 | * depending on the value of the ReturnDateType flag |
||
191 | 1 | */ |
|
192 | 1 | public static function DATENOW() |
|
216 | |||
217 | /** |
||
218 | * DATE. |
||
219 | * |
||
220 | * The DATE function returns a value that represents a particular date. |
||
221 | * |
||
222 | * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date |
||
223 | * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. |
||
224 | * |
||
225 | * Excel Function: |
||
226 | * DATE(year,month,day) |
||
227 | * |
||
228 | * PhpSpreadsheet is a lot more forgiving than MS Excel when passing non numeric values to this function. |
||
229 | * A Month name or abbreviation (English only at this point) such as 'January' or 'Jan' will still be accepted, |
||
230 | * as will a day value with a suffix (e.g. '21st' rather than simply 21); again only English language. |
||
231 | * |
||
232 | * @category Date/Time Functions |
||
233 | * |
||
234 | * @param int $year The value of the year argument can include one to four digits. |
||
235 | * Excel interprets the year argument according to the configured |
||
236 | * date system: 1900 or 1904. |
||
237 | * If year is between 0 (zero) and 1899 (inclusive), Excel adds that |
||
238 | * value to 1900 to calculate the year. For example, DATE(108,1,2) |
||
239 | * returns January 2, 2008 (1900+108). |
||
240 | * If year is between 1900 and 9999 (inclusive), Excel uses that |
||
241 | * value as the year. For example, DATE(2008,1,2) returns January 2, |
||
242 | * 2008. |
||
243 | * If year is less than 0 or is 10000 or greater, Excel returns the |
||
244 | * #NUM! error value. |
||
245 | * @param int $month A positive or negative integer representing the month of the year |
||
246 | * from 1 to 12 (January to December). |
||
247 | * If month is greater than 12, month adds that number of months to |
||
248 | * the first month in the year specified. For example, DATE(2008,14,2) |
||
249 | * returns the serial number representing February 2, 2009. |
||
250 | * If month is less than 1, month subtracts the magnitude of that |
||
251 | * number of months, plus 1, from the first month in the year |
||
252 | * specified. For example, DATE(2008,-3,2) returns the serial number |
||
253 | * representing September 2, 2007. |
||
254 | * @param int $day A positive or negative integer representing the day of the month |
||
255 | * from 1 to 31. |
||
256 | * If day is greater than the number of days in the month specified, |
||
257 | * day adds that number of days to the first day in the month. For |
||
258 | * example, DATE(2008,1,35) returns the serial number representing |
||
259 | * February 4, 2008. |
||
260 | * If day is less than 1, day subtracts the magnitude that number of |
||
261 | * days, plus one, from the first day of the month specified. For |
||
262 | 84 | * example, DATE(2008,1,-15) returns the serial number representing |
|
263 | * December 16, 2007. |
||
264 | 84 | * |
|
265 | 84 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
|
266 | 84 | * depending on the value of the ReturnDateType flag |
|
267 | */ |
||
268 | 84 | public static function DATE($year = 0, $month = 1, $day = 1) |
|
334 | |||
335 | /** |
||
336 | * TIME. |
||
337 | * |
||
338 | * The TIME function returns a value that represents a particular time. |
||
339 | * |
||
340 | * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the time |
||
341 | * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. |
||
342 | * |
||
343 | * Excel Function: |
||
344 | * TIME(hour,minute,second) |
||
345 | * |
||
346 | * @category Date/Time Functions |
||
347 | * |
||
348 | * @param int $hour A number from 0 (zero) to 32767 representing the hour. |
||
349 | * Any value greater than 23 will be divided by 24 and the remainder |
||
350 | * will be treated as the hour value. For example, TIME(27,0,0) = |
||
351 | * TIME(3,0,0) = .125 or 3:00 AM. |
||
352 | * @param int $minute A number from 0 to 32767 representing the minute. |
||
353 | * Any value greater than 59 will be converted to hours and minutes. |
||
354 | * For example, TIME(0,750,0) = TIME(12,30,0) = .520833 or 12:30 PM. |
||
355 | * @param int $second A number from 0 to 32767 representing the second. |
||
356 | * Any value greater than 59 will be converted to hours, minutes, |
||
357 | 25 | * and seconds. For example, TIME(0,0,2000) = TIME(0,33,22) = .023148 |
|
358 | * or 12:33:20 AM |
||
359 | 25 | * |
|
360 | 25 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
|
361 | 25 | * depending on the value of the ReturnDateType flag |
|
362 | */ |
||
363 | 25 | public static function TIME($hour = 0, $minute = 0, $second = 0) |
|
445 | |||
446 | /** |
||
447 | * DATEVALUE. |
||
448 | * |
||
449 | * Returns a value that represents a particular date. |
||
450 | * Use DATEVALUE to convert a date represented by a text string to an Excel or PHP date/time stamp |
||
451 | * value. |
||
452 | * |
||
453 | * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date |
||
454 | * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. |
||
455 | * |
||
456 | * Excel Function: |
||
457 | * DATEVALUE(dateValue) |
||
458 | * |
||
459 | * @category Date/Time Functions |
||
460 | * |
||
461 | * @param string $dateValue Text that represents a date in a Microsoft Excel date format. |
||
462 | * For example, "1/30/2008" or "30-Jan-2008" are text strings within |
||
463 | * quotation marks that represent dates. Using the default date |
||
464 | * system in Excel for Windows, date_text must represent a date from |
||
465 | * January 1, 1900, to December 31, 9999. Using the default date |
||
466 | * system in Excel for the Macintosh, date_text must represent a date |
||
467 | 425 | * from January 1, 1904, to December 31, 9999. DATEVALUE returns the |
|
468 | * #VALUE! error value if date_text is out of this range. |
||
469 | 425 | * |
|
470 | 425 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
|
471 | * depending on the value of the ReturnDateType flag |
||
472 | 425 | */ |
|
473 | public static function DATEVALUE($dateValue = 1) |
||
581 | |||
582 | /** |
||
583 | * TIMEVALUE. |
||
584 | * |
||
585 | * Returns a value that represents a particular time. |
||
586 | * Use TIMEVALUE to convert a time represented by a text string to an Excel or PHP date/time stamp |
||
587 | * value. |
||
588 | * |
||
589 | * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the time |
||
590 | * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. |
||
591 | * |
||
592 | * Excel Function: |
||
593 | * TIMEVALUE(timeValue) |
||
594 | * |
||
595 | * @category Date/Time Functions |
||
596 | * |
||
597 | * @param string $timeValue A text string that represents a time in any one of the Microsoft |
||
598 | * Excel time formats; for example, "6:45 PM" and "18:45" text strings |
||
599 | 31 | * within quotation marks that represent time. |
|
600 | * Date information in time_text is ignored. |
||
601 | 31 | * |
|
602 | 31 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
|
603 | * depending on the value of the ReturnDateType flag |
||
604 | 31 | */ |
|
605 | 31 | public static function TIMEVALUE($timeValue) |
|
643 | |||
644 | /** |
||
645 | * DATEDIF. |
||
646 | * |
||
647 | * @param mixed $startDate Excel date serial value, PHP date/time stamp, PHP DateTime object |
||
648 | * or a standard date string |
||
649 | 150 | * @param mixed $endDate Excel date serial value, PHP date/time stamp, PHP DateTime object |
|
650 | * or a standard date string |
||
651 | 150 | * @param string $unit |
|
652 | 150 | * |
|
653 | 150 | * @return int Interval between the dates |
|
654 | */ |
||
655 | 150 | public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D') |
|
766 | |||
767 | /** |
||
768 | * DAYS360. |
||
769 | * |
||
770 | * Returns the number of days between two dates based on a 360-day year (twelve 30-day months), |
||
771 | * which is used in some accounting calculations. Use this function to help compute payments if |
||
772 | * your accounting system is based on twelve 30-day months. |
||
773 | * |
||
774 | * Excel Function: |
||
775 | * DAYS360(startDate,endDate[,method]) |
||
776 | * |
||
777 | * @category Date/Time Functions |
||
778 | * |
||
779 | * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), |
||
780 | * PHP DateTime object, or a standard date string |
||
781 | * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), |
||
782 | * PHP DateTime object, or a standard date string |
||
783 | * @param bool $method US or European Method |
||
784 | * FALSE or omitted: U.S. (NASD) method. If the starting date is |
||
785 | 72 | * the last day of a month, it becomes equal to the 30th of the |
|
786 | * same month. If the ending date is the last day of a month and |
||
787 | 72 | * the starting date is earlier than the 30th of a month, the |
|
788 | 72 | * ending date becomes equal to the 1st of the next month; |
|
789 | * otherwise the ending date becomes equal to the 30th of the |
||
790 | 72 | * same month. |
|
791 | 1 | * TRUE: European method. Starting dates and ending dates that |
|
792 | * occur on the 31st of a month become equal to the 30th of the |
||
793 | 71 | * same month. |
|
794 | 1 | * |
|
795 | * @return int Number of days between start date and end date |
||
796 | */ |
||
797 | 70 | public static function DAYS360($startDate = 0, $endDate = 0, $method = false) |
|
826 | |||
827 | /** |
||
828 | * YEARFRAC. |
||
829 | * |
||
830 | * Calculates the fraction of the year represented by the number of whole days between two dates |
||
831 | * (the start_date and the end_date). |
||
832 | * Use the YEARFRAC worksheet function to identify the proportion of a whole year's benefits or |
||
833 | * obligations to assign to a specific term. |
||
834 | * |
||
835 | * Excel Function: |
||
836 | * YEARFRAC(startDate,endDate[,method]) |
||
837 | * |
||
838 | * @category Date/Time Functions |
||
839 | * |
||
840 | * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), |
||
841 | 89 | * PHP DateTime object, or a standard date string |
|
842 | * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), |
||
843 | 89 | * PHP DateTime object, or a standard date string |
|
844 | 89 | * @param int $method Method used for the calculation |
|
845 | 89 | * 0 or omitted US (NASD) 30/360 |
|
846 | * 1 Actual/actual |
||
847 | 89 | * 2 Actual/360 |
|
848 | 4 | * 3 Actual/365 |
|
849 | * 4 European 30/360 |
||
850 | 85 | * |
|
851 | * @return float fraction of the year |
||
852 | */ |
||
853 | public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0) |
||
926 | |||
927 | /** |
||
928 | * NETWORKDAYS. |
||
929 | * |
||
930 | * Returns the number of whole working days between start_date and end_date. Working days |
||
931 | * exclude weekends and any dates identified in holidays. |
||
932 | * Use NETWORKDAYS to calculate employee benefits that accrue based on the number of days |
||
933 | * worked during a specific term. |
||
934 | * |
||
935 | 18 | * Excel Function: |
|
936 | * NETWORKDAYS(startDate,endDate[,holidays[,holiday[,...]]]) |
||
937 | * |
||
938 | 18 | * @category Date/Time Functions |
|
939 | 18 | * |
|
940 | * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), |
||
941 | 18 | * PHP DateTime object, or a standard date string |
|
942 | * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), |
||
943 | * PHP DateTime object, or a standard date string |
||
944 | 18 | * |
|
945 | * @return int Interval between the dates |
||
946 | */ |
||
947 | 18 | public static function NETWORKDAYS($startDate, $endDate, ...$dateArgs) |
|
1006 | |||
1007 | /** |
||
1008 | * WORKDAY. |
||
1009 | * |
||
1010 | * Returns the date that is the indicated number of working days before or after a date (the |
||
1011 | * starting date). Working days exclude weekends and any dates identified as holidays. |
||
1012 | * Use WORKDAY to exclude weekends or holidays when you calculate invoice due dates, expected |
||
1013 | * delivery times, or the number of days of work performed. |
||
1014 | * |
||
1015 | * Excel Function: |
||
1016 | * WORKDAY(startDate,endDays[,holidays[,holiday[,...]]]) |
||
1017 | 13 | * |
|
1018 | * @category Date/Time Functions |
||
1019 | * |
||
1020 | 13 | * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), |
|
1021 | 13 | * PHP DateTime object, or a standard date string |
|
1022 | * @param int $endDays The number of nonweekend and nonholiday days before or after |
||
1023 | 13 | * startDate. A positive value for days yields a future date; a |
|
1024 | * negative value yields a past date. |
||
1025 | 13 | * |
|
1026 | 1 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
|
1027 | * depending on the value of the ReturnDateType flag |
||
1028 | 12 | */ |
|
1029 | 12 | public static function WORKDAY($startDate, $endDays, ...$dateArgs) |
|
1117 | |||
1118 | /** |
||
1119 | * DAYOFMONTH. |
||
1120 | 17 | * |
|
1121 | * Returns the day of the month, for a specified date. The day is given as an integer |
||
1122 | 17 | * ranging from 1 to 31. |
|
1123 | * |
||
1124 | 17 | * Excel Function: |
|
1125 | * DAY(dateValue) |
||
1126 | 17 | * |
|
1127 | 1 | * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
|
1128 | 16 | * PHP DateTime object, or a standard date string |
|
1129 | * |
||
1130 | 16 | * @return int Day of the month |
|
1131 | 1 | */ |
|
1132 | public static function DAYOFMONTH($dateValue = 1) |
||
1151 | |||
1152 | /** |
||
1153 | * WEEKDAY. |
||
1154 | * |
||
1155 | * Returns the day of the week for a specified date. The day is given as an integer |
||
1156 | * ranging from 0 to 7 (dependent on the requested style). |
||
1157 | * |
||
1158 | 57 | * Excel Function: |
|
1159 | * WEEKDAY(dateValue[,style]) |
||
1160 | 57 | * |
|
1161 | 57 | * @param int $dateValue Excel date serial value (float), PHP date timestamp (integer), |
|
1162 | * PHP DateTime object, or a standard date string |
||
1163 | 57 | * @param int $style A number that determines the type of return value |
|
1164 | 1 | * 1 or omitted Numbers 1 (Sunday) through 7 (Saturday). |
|
1165 | 56 | * 2 Numbers 1 (Monday) through 7 (Sunday). |
|
1166 | 1 | * 3 Numbers 0 (Monday) through 6 (Sunday). |
|
1167 | * |
||
1168 | 55 | * @return int Day of the week value |
|
1169 | */ |
||
1170 | 55 | public static function WEEKDAY($dateValue = 1, $style = 1) |
|
1227 | |||
1228 | /** |
||
1229 | * WEEKNUM. |
||
1230 | * |
||
1231 | * Returns the week of the year for a specified date. |
||
1232 | * The WEEKNUM function considers the week containing January 1 to be the first week of the year. |
||
1233 | * However, there is a European standard that defines the first week as the one with the majority |
||
1234 | 15 | * of days (four or more) falling in the new year. This means that for years in which there are |
|
1235 | * three days or less in the first week of January, the WEEKNUM function returns week numbers |
||
1236 | 15 | * that are incorrect according to the European standard. |
|
1237 | 15 | * |
|
1238 | * Excel Function: |
||
1239 | 15 | * WEEKNUM(dateValue[,style]) |
|
1240 | 1 | * |
|
1241 | 14 | * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
|
1242 | 1 | * PHP DateTime object, or a standard date string |
|
1243 | * @param int $method Week begins on Sunday or Monday |
||
1244 | 13 | * 1 or omitted Week begins on Sunday. |
|
1245 | * 2 Week begins on Monday. |
||
1246 | 13 | * |
|
1247 | * @return int Week Number |
||
1248 | 13 | */ |
|
1249 | 1 | public static function WEEKNUM($dateValue = 1, $method = 1) |
|
1284 | 21 | ||
1285 | /** |
||
1286 | 21 | * MONTHOFYEAR. |
|
1287 | * |
||
1288 | 21 | * Returns the month of a date represented by a serial number. |
|
1289 | 2 | * The month is given as an integer, ranging from 1 (January) to 12 (December). |
|
1290 | * |
||
1291 | 21 | * Excel Function: |
|
1292 | 1 | * MONTH(dateValue) |
|
1293 | 20 | * |
|
1294 | 1 | * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
|
1295 | * PHP DateTime object, or a standard date string |
||
1296 | * |
||
1297 | * @return int Month of the year |
||
1298 | 19 | */ |
|
1299 | View Code Duplication | public static function MONTHOFYEAR($dateValue = 1) |
|
1317 | 33 | ||
1318 | /** |
||
1319 | 33 | * YEAR. |
|
1320 | * |
||
1321 | 33 | * Returns the year corresponding to a date. |
|
1322 | 1 | * The year is returned as an integer in the range 1900-9999. |
|
1323 | 32 | * |
|
1324 | 1 | * Excel Function: |
|
1325 | 31 | * YEAR(dateValue) |
|
1326 | 1 | * |
|
1327 | * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
||
1328 | * PHP DateTime object, or a standard date string |
||
1329 | * |
||
1330 | 31 | * @return int Year |
|
1331 | */ |
||
1332 | 31 | View Code Duplication | public static function YEAR($dateValue = 1) |
1349 | 12 | ||
1350 | /** |
||
1351 | 12 | * HOUROFDAY. |
|
1352 | * |
||
1353 | 12 | * Returns the hour of a time value. |
|
1354 | 4 | * The hour is given as an integer, ranging from 0 (12:00 A.M.) to 23 (11:00 P.M.). |
|
1355 | * |
||
1356 | * Excel Function: |
||
1357 | * HOUR(timeValue) |
||
1358 | * |
||
1359 | * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer), |
||
1360 | 4 | * PHP DateTime object, or a standard time string |
|
1361 | 4 | * |
|
1362 | 1 | * @return int Hour |
|
1363 | */ |
||
1364 | View Code Duplication | public static function HOUROFDAY($timeValue = 0) |
|
1390 | 12 | ||
1391 | /** |
||
1392 | 12 | * MINUTE. |
|
1393 | * |
||
1394 | 12 | * Returns the minutes of a time value. |
|
1395 | 4 | * The minute is given as an integer, ranging from 0 to 59. |
|
1396 | * |
||
1397 | * Excel Function: |
||
1398 | * MINUTE(timeValue) |
||
1399 | * |
||
1400 | * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer), |
||
1401 | 4 | * PHP DateTime object, or a standard time string |
|
1402 | 4 | * |
|
1403 | 1 | * @return int Minute |
|
1404 | */ |
||
1405 | View Code Duplication | public static function MINUTE($timeValue = 0) |
|
1431 | 12 | ||
1432 | /** |
||
1433 | 12 | * SECOND. |
|
1434 | * |
||
1435 | 12 | * Returns the seconds of a time value. |
|
1436 | 4 | * The second is given as an integer in the range 0 (zero) to 59. |
|
1437 | * |
||
1438 | * Excel Function: |
||
1439 | * SECOND(timeValue) |
||
1440 | * |
||
1441 | * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer), |
||
1442 | 4 | * PHP DateTime object, or a standard time string |
|
1443 | 4 | * |
|
1444 | 1 | * @return int Second |
|
1445 | */ |
||
1446 | View Code Duplication | public static function SECOND($timeValue = 0) |
|
1472 | |||
1473 | /** |
||
1474 | * EDATE. |
||
1475 | * |
||
1476 | * Returns the serial number that represents the date that is the indicated number of months |
||
1477 | * before or after a specified date (the start_date). |
||
1478 | 17 | * Use EDATE to calculate maturity dates or due dates that fall on the same day of the month |
|
1479 | * as the date of issue. |
||
1480 | 17 | * |
|
1481 | 17 | * Excel Function: |
|
1482 | * EDATE(dateValue,adjustmentMonths) |
||
1483 | 17 | * |
|
1484 | 1 | * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
|
1485 | * PHP DateTime object, or a standard date string |
||
1486 | 16 | * @param int $adjustmentMonths The number of months before or after start_date. |
|
1487 | * A positive value for months yields a future date; |
||
1488 | 16 | * a negative value yields a past date. |
|
1489 | 1 | * |
|
1490 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
||
1491 | * depending on the value of the ReturnDateType flag |
||
1492 | */ |
||
1493 | 15 | public static function EDATE($dateValue = 1, $adjustmentMonths = 0) |
|
1519 | |||
1520 | /** |
||
1521 | * EOMONTH. |
||
1522 | * |
||
1523 | * Returns the date value for the last day of the month that is the indicated number of months |
||
1524 | 19 | * before or after start_date. |
|
1525 | * Use EOMONTH to calculate maturity dates or due dates that fall on the last day of the month. |
||
1526 | 19 | * |
|
1527 | 19 | * Excel Function: |
|
1528 | * EOMONTH(dateValue,adjustmentMonths) |
||
1529 | 19 | * |
|
1530 | 1 | * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), |
|
1531 | * PHP DateTime object, or a standard date string |
||
1532 | 18 | * @param int $adjustmentMonths The number of months before or after start_date. |
|
1533 | * A positive value for months yields a future date; |
||
1534 | 18 | * a negative value yields a past date. |
|
1535 | 1 | * |
|
1536 | * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, |
||
1537 | * depending on the value of the ReturnDateType flag |
||
1538 | */ |
||
1539 | 17 | public static function EOMONTH($dateValue = 1, $adjustmentMonths = 0) |
|
1568 | } |
||
1569 |
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.