Total Complexity | 48 |
Total Lines | 658 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like Calendar 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.
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 Calendar, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
121 | class Calendar |
||
122 | { |
||
123 | /** |
||
124 | * Instance of class implementing calendar engine interface |
||
125 | * @var object |
||
126 | * @access private |
||
127 | */ |
||
128 | var $cE; |
||
129 | |||
130 | /** |
||
131 | * Instance of Calendar_Validator (lazy initialized when isValid() or |
||
132 | * getValidor() is called |
||
133 | * @var Validator |
||
134 | * @access private |
||
135 | */ |
||
136 | var $validator; |
||
137 | |||
138 | /** |
||
139 | * Year for this calendar object e.g. 2003 |
||
140 | * @access private |
||
141 | * @var int |
||
142 | */ |
||
143 | var $year; |
||
144 | |||
145 | /** |
||
146 | * Month for this calendar object e.g. 9 |
||
147 | * @access private |
||
148 | * @var int |
||
149 | */ |
||
150 | var $month; |
||
151 | |||
152 | /** |
||
153 | * Day of month for this calendar object e.g. 23 |
||
154 | * @access private |
||
155 | * @var int |
||
156 | */ |
||
157 | var $day; |
||
158 | |||
159 | /** |
||
160 | * Hour of day for this calendar object e.g. 13 |
||
161 | * @access private |
||
162 | * @var int |
||
163 | */ |
||
164 | var $hour; |
||
165 | |||
166 | /** |
||
167 | * Minute of hour this calendar object e.g. 46 |
||
168 | * @access private |
||
169 | * @var int |
||
170 | */ |
||
171 | var $minute; |
||
172 | |||
173 | /** |
||
174 | * Second of minute this calendar object e.g. 34 |
||
175 | * @access private |
||
176 | * @var int |
||
177 | */ |
||
178 | var $second; |
||
179 | |||
180 | /** |
||
181 | * Marks this calendar object as selected (e.g. 'today') |
||
182 | * @access private |
||
183 | * @var boolean |
||
184 | */ |
||
185 | var $selected = false; |
||
186 | |||
187 | /** |
||
188 | * Collection of child calendar objects created from subclasses |
||
189 | * of Calendar. Type depends on the object which created them. |
||
190 | * @access private |
||
191 | * @var array |
||
192 | */ |
||
193 | var $children = array(); |
||
194 | |||
195 | /** |
||
196 | * Constructs the Calendar |
||
197 | * |
||
198 | * @param int $y year |
||
199 | * @param int $m month |
||
200 | * @param int $d day |
||
201 | * @param int $h hour |
||
202 | * @param int $i minute |
||
203 | * @param int $s second |
||
204 | * |
||
205 | * @access protected |
||
206 | */ |
||
207 | function __construct($y = 2000, $m = 1, $d = 1, $h = 0, $i = 0, $s = 0) |
||
|
|||
208 | { |
||
209 | static $cE = null; |
||
210 | if (!isset($cE)) { |
||
211 | $cE = & Calendar_Engine_Factory::getEngine(); |
||
212 | } |
||
213 | $this->cE = & $cE; |
||
214 | $this->year = (int)$y; |
||
215 | $this->month = (int)$m; |
||
216 | $this->day = (int)$d; |
||
217 | $this->hour = (int)$h; |
||
218 | $this->minute = (int)$i; |
||
219 | $this->second = (int)$s; |
||
220 | } |
||
221 | |||
222 | /** |
||
223 | * Defines the calendar by a timestamp (Unix or ISO-8601), replacing values |
||
224 | * passed to the constructor |
||
225 | * |
||
226 | * @param int|string $ts Unix or ISO-8601 timestamp |
||
227 | * |
||
228 | * @return void |
||
229 | * @access public |
||
230 | */ |
||
231 | function setTimestamp($ts) |
||
232 | { |
||
233 | $this->year = $this->cE->stampToYear($ts); |
||
234 | $this->month = $this->cE->stampToMonth($ts); |
||
235 | $this->day = $this->cE->stampToDay($ts); |
||
236 | $this->hour = $this->cE->stampToHour($ts); |
||
237 | $this->minute = $this->cE->stampToMinute($ts); |
||
238 | $this->second = $this->cE->stampToSecond($ts); |
||
239 | } |
||
240 | |||
241 | /** |
||
242 | * Returns a timestamp from the current date / time values. Format of |
||
243 | * timestamp depends on Calendar_Engine implementation being used |
||
244 | * |
||
245 | * @return int|string timestamp |
||
246 | * @access public |
||
247 | */ |
||
248 | function getTimestamp() |
||
249 | { |
||
250 | return $this->cE->dateToStamp( |
||
251 | $this->year, $this->month, $this->day, |
||
252 | $this->hour, $this->minute, $this->second); |
||
253 | } |
||
254 | |||
255 | /** |
||
256 | * Defines calendar object as selected (e.g. for today) |
||
257 | * |
||
258 | * @param boolean $state whether Calendar subclass |
||
259 | * |
||
260 | * @return void |
||
261 | * @access public |
||
262 | */ |
||
263 | function setSelected($state = true) |
||
264 | { |
||
265 | $this->selected = $state; |
||
266 | } |
||
267 | |||
268 | /** |
||
269 | * True if the calendar subclass object is selected (e.g. today) |
||
270 | * |
||
271 | * @return boolean |
||
272 | * @access public |
||
273 | */ |
||
274 | function isSelected() |
||
275 | { |
||
276 | return $this->selected; |
||
277 | } |
||
278 | |||
279 | /** |
||
280 | * Checks if the current Calendar object is today's date |
||
281 | * |
||
282 | * @return boolean |
||
283 | * @access public |
||
284 | */ |
||
285 | function isToday() |
||
286 | { |
||
287 | return $this->cE->isToday($this->getTimeStamp()); |
||
288 | } |
||
289 | |||
290 | /** |
||
291 | * Adjusts the date (helper method) |
||
292 | * |
||
293 | * @return void |
||
294 | * @access public |
||
295 | */ |
||
296 | function adjust() |
||
297 | { |
||
298 | $stamp = $this->getTimeStamp(); |
||
299 | $this->year = $this->cE->stampToYear($stamp); |
||
300 | $this->month = $this->cE->stampToMonth($stamp); |
||
301 | $this->day = $this->cE->stampToDay($stamp); |
||
302 | $this->hour = $this->cE->stampToHour($stamp); |
||
303 | $this->minute = $this->cE->stampToMinute($stamp); |
||
304 | $this->second = $this->cE->stampToSecond($stamp); |
||
305 | } |
||
306 | |||
307 | /** |
||
308 | * Returns the date as an associative array (helper method) |
||
309 | * |
||
310 | * @param mixed $stamp timestamp (leave empty for current timestamp) |
||
311 | * |
||
312 | * @return array |
||
313 | * @access public |
||
314 | */ |
||
315 | function toArray($stamp=null) |
||
316 | { |
||
317 | if (is_null($stamp)) { |
||
318 | $stamp = $this->getTimeStamp(); |
||
319 | } |
||
320 | return array( |
||
321 | 'year' => $this->cE->stampToYear($stamp), |
||
322 | 'month' => $this->cE->stampToMonth($stamp), |
||
323 | 'day' => $this->cE->stampToDay($stamp), |
||
324 | 'hour' => $this->cE->stampToHour($stamp), |
||
325 | 'minute' => $this->cE->stampToMinute($stamp), |
||
326 | 'second' => $this->cE->stampToSecond($stamp) |
||
327 | ); |
||
328 | } |
||
329 | |||
330 | /** |
||
331 | * Returns the value as an associative array (helper method) |
||
332 | * |
||
333 | * @param string $returnType type of date object that return value represents |
||
334 | * @param string $format ['int' | 'array' | 'timestamp' | 'object'] |
||
335 | * @param mixed $stamp timestamp (depending on Calendar engine being used) |
||
336 | * @param int $default default value (i.e. give me the answer quick) |
||
337 | * |
||
338 | * @return mixed |
||
339 | * @access private |
||
340 | */ |
||
341 | function returnValue($returnType, $format, $stamp, $default) |
||
342 | { |
||
343 | switch (strtolower($format)) { |
||
344 | case 'int': |
||
345 | return $default; |
||
346 | case 'array': |
||
347 | return $this->toArray($stamp); |
||
348 | break; |
||
349 | case 'object': |
||
350 | include_once CALENDAR_ROOT.'Factory.php'; |
||
351 | return Factory::createByTimestamp($returnType, $stamp); |
||
352 | break; |
||
353 | case 'timestamp': |
||
354 | default: |
||
355 | return $stamp; |
||
356 | break; |
||
357 | } |
||
358 | } |
||
359 | |||
360 | /** |
||
361 | * Abstract method for building the children of a calendar object. |
||
362 | * Implemented by Calendar subclasses |
||
363 | * |
||
364 | * @param array $sDates array containing Calendar objects to select (optional) |
||
365 | * |
||
366 | * @return boolean |
||
367 | * @access public |
||
368 | * @abstract |
||
369 | */ |
||
370 | function build($sDates = array()) |
||
371 | { |
||
372 | include_once 'PEAR.php'; |
||
373 | PEAR::raiseError('Calendar::build is abstract', null, PEAR_ERROR_TRIGGER, |
||
374 | E_USER_NOTICE, 'Calendar::build()'); |
||
375 | return false; |
||
376 | } |
||
377 | |||
378 | /** |
||
379 | * Abstract method for selected data objects called from build |
||
380 | * |
||
381 | * @param array $sDates array of Calendar objects to select |
||
382 | * |
||
383 | * @return boolean |
||
384 | * @access public |
||
385 | * @abstract |
||
386 | */ |
||
387 | function setSelection($sDates) |
||
388 | { |
||
389 | include_once 'PEAR.php'; |
||
390 | PEAR::raiseError( |
||
391 | 'Calendar::setSelection is abstract', null, PEAR_ERROR_TRIGGER, |
||
392 | E_USER_NOTICE, 'Calendar::setSelection()'); |
||
393 | return false; |
||
394 | } |
||
395 | |||
396 | /** |
||
397 | * Iterator method for fetching child Calendar subclass objects |
||
398 | * (e.g. a minute from an hour object). On reaching the end of |
||
399 | * the collection, returns false and resets the collection for |
||
400 | * further iteratations. |
||
401 | * |
||
402 | * @return mixed either an object subclass of Calendar or false |
||
403 | * @access public |
||
404 | */ |
||
405 | function fetch() |
||
406 | { |
||
407 | $child = each($this->children); |
||
408 | if ($child) { |
||
409 | return $child['value']; |
||
410 | } else { |
||
411 | reset($this->children); |
||
412 | return false; |
||
413 | } |
||
414 | } |
||
415 | |||
416 | /** |
||
417 | * Fetches all child from the current collection of children |
||
418 | * |
||
419 | * @return array |
||
420 | * @access public |
||
421 | */ |
||
422 | function fetchAll() |
||
423 | { |
||
424 | return $this->children; |
||
425 | } |
||
426 | |||
427 | /** |
||
428 | * Get the number Calendar subclass objects stored in the internal collection |
||
429 | * |
||
430 | * @return int |
||
431 | * @access public |
||
432 | */ |
||
433 | function size() |
||
434 | { |
||
435 | return count($this->children); |
||
436 | } |
||
437 | |||
438 | /** |
||
439 | * Determine whether this date is valid, with the bounds determined by |
||
440 | * the Calendar_Engine. The call is passed on to Calendar_Validator::isValid |
||
441 | * |
||
442 | * @return boolean |
||
443 | * @access public |
||
444 | */ |
||
445 | function isValid() |
||
446 | { |
||
447 | $validator = & $this->getValidator(); |
||
448 | return $validator->isValid(); |
||
449 | } |
||
450 | |||
451 | /** |
||
452 | * Returns an instance of Calendar_Validator |
||
453 | * |
||
454 | * @return Validator |
||
455 | * @access public |
||
456 | */ |
||
457 | function & getValidator() |
||
458 | { |
||
459 | if (!isset($this->validator)) { |
||
460 | include_once CALENDAR_ROOT.'Validator.php'; |
||
461 | $this->validator = new Validator($this); |
||
462 | } |
||
463 | return $this->validator; |
||
464 | } |
||
465 | |||
466 | /** |
||
467 | * Returns a reference to the current Calendar_Engine being used. Useful |
||
468 | * for Calendar_Table_Helper and Calendar_Validator |
||
469 | * |
||
470 | * @return object implementing Calendar_Engine_Inteface |
||
471 | * @access protected |
||
472 | */ |
||
473 | function & getEngine() |
||
474 | { |
||
475 | return $this->cE; |
||
476 | } |
||
477 | |||
478 | /** |
||
479 | * Set the CALENDAR_FIRST_DAY_OF_WEEK constant to the $firstDay value |
||
480 | * if the constant is not set yet. |
||
481 | * |
||
482 | * @param integer $firstDay first day of the week (0=sunday, 1=monday, ...) |
||
483 | * |
||
484 | * @return integer |
||
485 | * @throws E_USER_WARNING this method throws a WARNING if the |
||
486 | * CALENDAR_FIRST_DAY_OF_WEEK constant is already defined and |
||
487 | * the $firstDay parameter is set to a different value |
||
488 | * @access protected |
||
489 | */ |
||
490 | function defineFirstDayOfWeek($firstDay = null) |
||
491 | { |
||
492 | if (defined('CALENDAR_FIRST_DAY_OF_WEEK')) { |
||
493 | if (!is_null($firstDay) && ($firstDay != CALENDAR_FIRST_DAY_OF_WEEK)) { |
||
494 | $msg = 'CALENDAR_FIRST_DAY_OF_WEEK constant already defined.' |
||
495 | .' The $firstDay parameter will be ignored.'; |
||
496 | trigger_error($msg, E_USER_WARNING); |
||
497 | } |
||
498 | return CALENDAR_FIRST_DAY_OF_WEEK; |
||
499 | } |
||
500 | if (is_null($firstDay)) { |
||
501 | $firstDay = $this->cE->getFirstDayOfWeek( |
||
502 | $this->thisYear(), |
||
503 | $this->thisMonth(), |
||
504 | $this->thisDay() |
||
505 | ); |
||
506 | } |
||
507 | define ('CALENDAR_FIRST_DAY_OF_WEEK', $firstDay); |
||
508 | return CALENDAR_FIRST_DAY_OF_WEEK; |
||
509 | } |
||
510 | |||
511 | /** |
||
512 | * Returns the value for the previous year |
||
513 | * |
||
514 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||
515 | * |
||
516 | * @return int e.g. 2002 or timestamp |
||
517 | * @access public |
||
518 | */ |
||
519 | function prevYear($format = 'int') |
||
520 | { |
||
521 | $ts = $this->cE->dateToStamp($this->year-1, 1, 1, 0, 0, 0); |
||
522 | return $this->returnValue('Year', $format, $ts, $this->year-1); |
||
523 | } |
||
524 | |||
525 | /** |
||
526 | * Returns the value for this year |
||
527 | * |
||
528 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||
529 | * |
||
530 | * @return int e.g. 2003 or timestamp |
||
531 | * @access public |
||
532 | */ |
||
533 | function thisYear($format = 'int') |
||
534 | { |
||
535 | $ts = $this->cE->dateToStamp($this->year, 1, 1, 0, 0, 0); |
||
536 | return $this->returnValue('Year', $format, $ts, $this->year); |
||
537 | } |
||
538 | |||
539 | /** |
||
540 | * Returns the value for next year |
||
541 | * |
||
542 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||
543 | * |
||
544 | * @return int e.g. 2004 or timestamp |
||
545 | * @access public |
||
546 | */ |
||
547 | function nextYear($format = 'int') |
||
548 | { |
||
549 | $ts = $this->cE->dateToStamp($this->year+1, 1, 1, 0, 0, 0); |
||
550 | return $this->returnValue('Year', $format, $ts, $this->year+1); |
||
551 | } |
||
552 | |||
553 | /** |
||
554 | * Returns the value for the previous month |
||
555 | * |
||
556 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||
557 | * |
||
558 | * @return int e.g. 4 or Unix timestamp |
||
559 | * @access public |
||
560 | */ |
||
561 | function prevMonth($format = 'int') |
||
562 | { |
||
563 | $ts = $this->cE->dateToStamp($this->year, $this->month-1, 1, 0, 0, 0); |
||
564 | return $this->returnValue('Month', $format, $ts, $this->cE->stampToMonth($ts)); |
||
565 | } |
||
566 | |||
567 | /** |
||
568 | * Returns the value for this month |
||
569 | * |
||
570 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||
571 | * |
||
572 | * @return int e.g. 5 or timestamp |
||
573 | * @access public |
||
574 | */ |
||
575 | function thisMonth($format = 'int') |
||
576 | { |
||
577 | $ts = $this->cE->dateToStamp($this->year, $this->month, 1, 0, 0, 0); |
||
578 | return $this->returnValue('Month', $format, $ts, $this->month); |
||
579 | } |
||
580 | |||
581 | /** |
||
582 | * Returns the value for next month |
||
583 | * |
||
584 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||
585 | * |
||
586 | * @return int e.g. 6 or timestamp |
||
587 | * @access public |
||
588 | */ |
||
589 | function nextMonth($format = 'int') |
||
590 | { |
||
591 | $ts = $this->cE->dateToStamp($this->year, $this->month+1, 1, 0, 0, 0); |
||
592 | return $this->returnValue('Month', $format, $ts, $this->cE->stampToMonth($ts)); |
||
593 | } |
||
594 | |||
595 | /** |
||
596 | * Returns the value for the previous day |
||
597 | * |
||
598 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||
599 | * |
||
600 | * @return int e.g. 10 or timestamp |
||
601 | * @access public |
||
602 | */ |
||
603 | function prevDay($format = 'int') |
||
604 | { |
||
605 | $ts = $this->cE->dateToStamp( |
||
606 | $this->year, $this->month, $this->day-1, 0, 0, 0); |
||
607 | return $this->returnValue('Day', $format, $ts, $this->cE->stampToDay($ts)); |
||
608 | } |
||
609 | |||
610 | /** |
||
611 | * Returns the value for this day |
||
612 | * |
||
613 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||
614 | * |
||
615 | * @return int e.g. 11 or timestamp |
||
616 | * @access public |
||
617 | */ |
||
618 | function thisDay($format = 'int') |
||
623 | } |
||
624 | |||
625 | /** |
||
626 | * Returns the value for the next day |
||
627 | * |
||
628 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||
629 | * |
||
630 | * @return int e.g. 12 or timestamp |
||
631 | * @access public |
||
632 | */ |
||
633 | function nextDay($format = 'int') |
||
634 | { |
||
635 | $ts = $this->cE->dateToStamp( |
||
636 | $this->year, $this->month, $this->day+1, 0, 0, 0); |
||
637 | return $this->returnValue('Day', $format, $ts, $this->cE->stampToDay($ts)); |
||
638 | } |
||
639 | |||
640 | /** |
||
641 | * Returns the value for the previous hour |
||
642 | * |
||
643 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||
644 | * |
||
645 | * @return int e.g. 13 or timestamp |
||
646 | * @access public |
||
647 | */ |
||
648 | function prevHour($format = 'int') |
||
649 | { |
||
650 | $ts = $this->cE->dateToStamp( |
||
651 | $this->year, $this->month, $this->day, $this->hour-1, 0, 0); |
||
652 | return $this->returnValue('Hour', $format, $ts, $this->cE->stampToHour($ts)); |
||
653 | } |
||
654 | |||
655 | /** |
||
656 | * Returns the value for this hour |
||
657 | * |
||
658 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||
659 | * |
||
660 | * @return int e.g. 14 or timestamp |
||
661 | * @access public |
||
662 | */ |
||
663 | function thisHour($format = 'int') |
||
664 | { |
||
665 | $ts = $this->cE->dateToStamp( |
||
666 | $this->year, $this->month, $this->day, $this->hour, 0, 0); |
||
667 | return $this->returnValue('Hour', $format, $ts, $this->hour); |
||
668 | } |
||
669 | |||
670 | /** |
||
671 | * Returns the value for the next hour |
||
672 | * |
||
673 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||
674 | * |
||
675 | * @return int e.g. 14 or timestamp |
||
676 | * @access public |
||
677 | */ |
||
678 | function nextHour($format = 'int') |
||
683 | } |
||
684 | |||
685 | /** |
||
686 | * Returns the value for the previous minute |
||
687 | * |
||
688 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||
689 | * |
||
690 | * @return int e.g. 23 or timestamp |
||
691 | * @access public |
||
692 | */ |
||
693 | function prevMinute($format = 'int') |
||
694 | { |
||
695 | $ts = $this->cE->dateToStamp( |
||
696 | $this->year, $this->month, $this->day, |
||
697 | $this->hour, $this->minute-1, 0); |
||
698 | return $this->returnValue('Minute', $format, $ts, $this->cE->stampToMinute($ts)); |
||
699 | } |
||
700 | |||
701 | /** |
||
702 | * Returns the value for this minute |
||
703 | * |
||
704 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||
705 | * |
||
706 | * @return int e.g. 24 or timestamp |
||
707 | * @access public |
||
708 | */ |
||
709 | function thisMinute($format = 'int') |
||
710 | { |
||
711 | $ts = $this->cE->dateToStamp( |
||
712 | $this->year, $this->month, $this->day, |
||
713 | $this->hour, $this->minute, 0); |
||
714 | return $this->returnValue('Minute', $format, $ts, $this->minute); |
||
715 | } |
||
716 | |||
717 | /** |
||
718 | * Returns the value for the next minute |
||
719 | * |
||
720 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||
721 | * |
||
722 | * @return int e.g. 25 or timestamp |
||
723 | * @access public |
||
724 | */ |
||
725 | function nextMinute($format = 'int') |
||
726 | { |
||
727 | $ts = $this->cE->dateToStamp( |
||
728 | $this->year, $this->month, $this->day, |
||
729 | $this->hour, $this->minute+1, 0); |
||
730 | return $this->returnValue('Minute', $format, $ts, $this->cE->stampToMinute($ts)); |
||
731 | } |
||
732 | |||
733 | /** |
||
734 | * Returns the value for the previous second |
||
735 | * |
||
736 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||
737 | * |
||
738 | * @return int e.g. 43 or timestamp |
||
739 | * @access public |
||
740 | */ |
||
741 | function prevSecond($format = 'int') |
||
742 | { |
||
743 | $ts = $this->cE->dateToStamp( |
||
744 | $this->year, $this->month, $this->day, |
||
745 | $this->hour, $this->minute, $this->second-1); |
||
746 | return $this->returnValue('Second', $format, $ts, $this->cE->stampToSecond($ts)); |
||
747 | } |
||
748 | |||
749 | /** |
||
750 | * Returns the value for this second |
||
751 | * |
||
752 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||
753 | * |
||
754 | * @return int e.g. 44 or timestamp |
||
755 | * @access public |
||
756 | */ |
||
757 | function thisSecond($format = 'int') |
||
758 | { |
||
759 | $ts = $this->cE->dateToStamp( |
||
760 | $this->year, $this->month, $this->day, |
||
761 | $this->hour, $this->minute, $this->second); |
||
762 | return $this->returnValue('Second', $format, $ts, $this->second); |
||
763 | } |
||
764 | |||
765 | /** |
||
766 | * Returns the value for the next second |
||
767 | * |
||
768 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||
769 | * |
||
770 | * @return int e.g. 45 or timestamp |
||
771 | * @access public |
||
772 | */ |
||
773 | function nextSecond($format = 'int') |
||
779 | } |
||
780 | } |
||
781 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.