This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
1 | <?php |
||||
2 | |||||
3 | /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ |
||||
4 | |||||
5 | /** |
||||
6 | * Contains the Calendar and Calendar_Engine_Factory classes. |
||||
7 | * |
||||
8 | * PHP versions 4 and 5 |
||||
9 | * |
||||
10 | * LICENSE: Redistribution and use in source and binary forms, with or without |
||||
11 | * modification, are permitted provided that the following conditions are met: |
||||
12 | * 1. Redistributions of source code must retain the above copyright |
||||
13 | * notice, this list of conditions and the following disclaimer. |
||||
14 | * 2. Redistributions in binary form must reproduce the above copyright |
||||
15 | * notice, this list of conditions and the following disclaimer in the |
||||
16 | * documentation and/or other materials provided with the distribution. |
||||
17 | * 3. The name of the author may not be used to endorse or promote products |
||||
18 | * derived from this software without specific prior written permission. |
||||
19 | * |
||||
20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED |
||||
21 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
||||
22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||||
23 | * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY |
||||
24 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
||||
25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
||||
27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
||||
29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
30 | * |
||||
31 | * @category Date and Time |
||||
32 | * |
||||
33 | * @author Harry Fuecks <[email protected]> |
||||
34 | * @author Lorenzo Alberton <[email protected]> |
||||
35 | * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton |
||||
36 | * @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) |
||||
37 | * |
||||
38 | * @link http://pear.php.net/package/Calendar |
||||
39 | */ |
||||
40 | |||||
41 | /** |
||||
42 | * Allows Calendar include path to be redefined. |
||||
43 | */ |
||||
44 | if (!defined('CALENDAR_ROOT')) { |
||||
45 | define('CALENDAR_ROOT', 'Calendar/'); |
||||
46 | } |
||||
47 | |||||
48 | /* |
||||
49 | * Constant which defines the calculation engine to use |
||||
50 | */ |
||||
51 | if (!defined('CALENDAR_ENGINE')) { |
||||
52 | define('CALENDAR_ENGINE', 'UnixTS'); |
||||
53 | } |
||||
54 | |||||
55 | /* |
||||
56 | * Define Calendar Month states |
||||
57 | */ |
||||
58 | define('CALENDAR_USE_MONTH', 1); |
||||
59 | define('CALENDAR_USE_MONTH_WEEKDAYS', 2); |
||||
60 | define('CALENDAR_USE_MONTH_WEEKS', 3); |
||||
61 | |||||
62 | /** |
||||
63 | * Contains a factory method to return a Singleton instance of a class |
||||
64 | * implementing the Calendar_Engine_Interface.<br> |
||||
65 | * <b>Note:</b> this class must be modified to "register" alternative |
||||
66 | * Calendar_Engines. The engine used can be controlled with the constant |
||||
67 | * CALENDAR_ENGINE. |
||||
68 | * |
||||
69 | * @category Date and Time |
||||
70 | * |
||||
71 | * @author Harry Fuecks <[email protected]> |
||||
72 | * @author Lorenzo Alberton <[email protected]> |
||||
73 | * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton |
||||
74 | * @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) |
||||
75 | * |
||||
76 | * @link http://pear.php.net/package/Calendar |
||||
77 | * @see Calendar_Engine_Interface |
||||
78 | */ |
||||
79 | class Calendar_Engine_Factory |
||||
80 | { |
||||
81 | /** |
||||
82 | * Returns an instance of the engine. |
||||
83 | * |
||||
84 | * @return bool instance of a calendar calculation engine |
||||
85 | */ |
||||
86 | public static function &getEngine() |
||||
87 | { |
||||
88 | static $engine = false; |
||||
89 | switch (CALENDAR_ENGINE) { |
||||
90 | case 'PearDate': |
||||
91 | $class = 'Calendar_Engine_PearDate'; |
||||
92 | break; |
||||
93 | case 'UnixTS': |
||||
94 | default: |
||||
95 | $class = 'Calendar_Engine_UnixTS'; |
||||
96 | break; |
||||
97 | } |
||||
98 | if (!$engine) { |
||||
99 | if (!class_exists($class)) { |
||||
100 | require_once CALENDAR_ROOT . 'Engine' . '/' . CALENDAR_ENGINE . '.php'; |
||||
101 | } |
||||
102 | $engine = new $class(); |
||||
103 | } |
||||
104 | |||||
105 | return $engine; |
||||
106 | } |
||||
107 | } |
||||
108 | |||||
109 | /** |
||||
110 | * Base class for Calendar API. This class should not be instantiated directly. |
||||
111 | * |
||||
112 | * @category Date and Time |
||||
113 | * |
||||
114 | * @author Harry Fuecks <[email protected]> |
||||
115 | * @author Lorenzo Alberton <[email protected]> |
||||
116 | * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton |
||||
117 | * @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) |
||||
118 | * |
||||
119 | * @link http://pear.php.net/package/Calendar |
||||
120 | * @abstract |
||||
121 | */ |
||||
122 | class Calendar |
||||
123 | { |
||||
124 | /** |
||||
125 | * Instance of class implementing calendar engine interface. |
||||
126 | * |
||||
127 | * @var object |
||||
128 | */ |
||||
129 | public $cE; |
||||
130 | |||||
131 | /** |
||||
132 | * Instance of Calendar_Validator (lazy initialized when isValid() or |
||||
133 | * getValidor() is called. |
||||
134 | * |
||||
135 | * @var Calendar_Validator |
||||
136 | */ |
||||
137 | public $validator; |
||||
138 | |||||
139 | /** |
||||
140 | * Year for this calendar object e.g. 2003. |
||||
141 | * |
||||
142 | * @var int |
||||
143 | */ |
||||
144 | public $year; |
||||
145 | |||||
146 | /** |
||||
147 | * Month for this calendar object e.g. 9. |
||||
148 | * |
||||
149 | * @var int |
||||
150 | */ |
||||
151 | public $month; |
||||
152 | |||||
153 | /** |
||||
154 | * Day of month for this calendar object e.g. 23. |
||||
155 | * |
||||
156 | * @var int |
||||
157 | */ |
||||
158 | public $day; |
||||
159 | |||||
160 | /** |
||||
161 | * Hour of day for this calendar object e.g. 13. |
||||
162 | * |
||||
163 | * @var int |
||||
164 | */ |
||||
165 | public $hour; |
||||
166 | |||||
167 | /** |
||||
168 | * Minute of hour this calendar object e.g. 46. |
||||
169 | * |
||||
170 | * @var int |
||||
171 | */ |
||||
172 | public $minute; |
||||
173 | |||||
174 | /** |
||||
175 | * Second of minute this calendar object e.g. 34. |
||||
176 | * |
||||
177 | * @var int |
||||
178 | */ |
||||
179 | public $second; |
||||
180 | |||||
181 | /** |
||||
182 | * Marks this calendar object as selected (e.g. 'today'). |
||||
183 | * |
||||
184 | * @var bool |
||||
185 | */ |
||||
186 | public $selected = false; |
||||
187 | |||||
188 | /** |
||||
189 | * Collection of child calendar objects created from subclasses |
||||
190 | * of Calendar. Type depends on the object which created them. |
||||
191 | * |
||||
192 | * @var array |
||||
193 | */ |
||||
194 | public $children = []; |
||||
195 | |||||
196 | /** |
||||
197 | * Constructs the Calendar. |
||||
198 | * |
||||
199 | * @param int $y year |
||||
200 | * @param int $m month |
||||
201 | * @param int $d day |
||||
202 | * @param int $h hour |
||||
203 | * @param int $i minute |
||||
204 | * @param int $s second |
||||
205 | */ |
||||
206 | public function __construct($y = 2000, $m = 1, $d = 1, $h = 0, $i = 0, $s = 0) |
||||
207 | { |
||||
208 | static $cE = null; |
||||
209 | if (!isset($cE)) { |
||||
210 | $cE = Calendar_Engine_Factory::getEngine(); |
||||
211 | } |
||||
212 | $this->cE = &$cE; |
||||
213 | $this->year = (int)$y; |
||||
214 | $this->month = (int)$m; |
||||
215 | $this->day = (int)$d; |
||||
216 | $this->hour = (int)$h; |
||||
217 | $this->minute = (int)$i; |
||||
218 | $this->second = (int)$s; |
||||
219 | } |
||||
220 | |||||
221 | /** |
||||
222 | * Defines the calendar by a timestamp (Unix or ISO-8601), replacing values |
||||
223 | * passed to the constructor. |
||||
224 | * |
||||
225 | * @param int|string $ts Unix or ISO-8601 timestamp |
||||
226 | */ |
||||
227 | public function setTimestamp($ts) |
||||
228 | { |
||||
229 | $this->year = $this->cE->stampToYear($ts); |
||||
230 | $this->month = $this->cE->stampToMonth($ts); |
||||
231 | $this->day = $this->cE->stampToDay($ts); |
||||
232 | $this->hour = $this->cE->stampToHour($ts); |
||||
233 | $this->minute = $this->cE->stampToMinute($ts); |
||||
234 | $this->second = $this->cE->stampToSecond($ts); |
||||
235 | } |
||||
236 | |||||
237 | /** |
||||
238 | * Returns a timestamp from the current date / time values. Format of |
||||
239 | * timestamp depends on Calendar_Engine implementation being used. |
||||
240 | * |
||||
241 | * @return int|string timestamp |
||||
242 | */ |
||||
243 | public function getTimestamp() |
||||
244 | { |
||||
245 | return $this->cE->dateToStamp($this->year, $this->month, $this->day, $this->hour, $this->minute, $this->second); |
||||
246 | } |
||||
247 | |||||
248 | /** |
||||
249 | * Defines calendar object as selected (e.g. for today). |
||||
250 | * |
||||
251 | * @param bool $state whether Calendar subclass |
||||
252 | */ |
||||
253 | public function setSelected($state = true) |
||||
254 | { |
||||
255 | $this->selected = $state; |
||||
256 | } |
||||
257 | |||||
258 | /** |
||||
259 | * True if the calendar subclass object is selected (e.g. today). |
||||
260 | * |
||||
261 | * @return bool |
||||
262 | */ |
||||
263 | public function isSelected() |
||||
264 | { |
||||
265 | return $this->selected; |
||||
266 | } |
||||
267 | |||||
268 | /** |
||||
269 | * Checks if the current Calendar object is today's date. |
||||
270 | * |
||||
271 | * @return bool |
||||
272 | */ |
||||
273 | public function isToday() |
||||
274 | { |
||||
275 | return $this->cE->isToday($this->getTimestamp()); |
||||
276 | } |
||||
277 | |||||
278 | /** |
||||
279 | * Adjusts the date (helper method). |
||||
280 | */ |
||||
281 | public function adjust() |
||||
282 | { |
||||
283 | $stamp = $this->getTimestamp(); |
||||
284 | $this->year = $this->cE->stampToYear($stamp); |
||||
285 | $this->month = $this->cE->stampToMonth($stamp); |
||||
286 | $this->day = $this->cE->stampToDay($stamp); |
||||
287 | $this->hour = $this->cE->stampToHour($stamp); |
||||
288 | $this->minute = $this->cE->stampToMinute($stamp); |
||||
289 | $this->second = $this->cE->stampToSecond($stamp); |
||||
290 | } |
||||
291 | |||||
292 | /** |
||||
293 | * Returns the date as an associative array (helper method). |
||||
294 | * |
||||
295 | * @param mixed $stamp timestamp (leave empty for current timestamp) |
||||
296 | * |
||||
297 | * @return array |
||||
298 | */ |
||||
299 | public function toArray($stamp = null) |
||||
300 | { |
||||
301 | if (null === $stamp) { |
||||
302 | $stamp = $this->getTimestamp(); |
||||
303 | } |
||||
304 | |||||
305 | return [ |
||||
306 | 'year' => $this->cE->stampToYear($stamp), |
||||
307 | 'month' => $this->cE->stampToMonth($stamp), |
||||
308 | 'day' => $this->cE->stampToDay($stamp), |
||||
309 | 'hour' => $this->cE->stampToHour($stamp), |
||||
310 | 'minute' => $this->cE->stampToMinute($stamp), |
||||
311 | 'second' => $this->cE->stampToSecond($stamp), |
||||
312 | ]; |
||||
313 | } |
||||
314 | |||||
315 | /** |
||||
316 | * Returns the value as an associative array (helper method). |
||||
317 | * |
||||
318 | * @param string $returnType type of date object that return value represents |
||||
319 | * @param string $format ['int' | 'array' | 'timestamp' | 'object'] |
||||
320 | * @param mixed $stamp timestamp (depending on Calendar engine being used) |
||||
321 | * @param int $default default value (i.e. give me the answer quick) |
||||
322 | * |
||||
323 | * @return mixed |
||||
324 | */ |
||||
325 | public function returnValue($returnType, $format, $stamp, $default) |
||||
326 | { |
||||
327 | switch (mb_strtolower($format)) { |
||||
328 | case 'int': |
||||
329 | return $default; |
||||
330 | case 'array': |
||||
331 | return $this->toArray($stamp); |
||||
332 | break; |
||||
0 ignored issues
–
show
|
|||||
333 | case 'object': |
||||
334 | require_once CALENDAR_ROOT . 'Factory.php'; |
||||
335 | |||||
336 | return Calendar_Factory::createByTimestamp($returnType, $stamp); |
||||
337 | break; |
||||
338 | case 'timestamp': |
||||
339 | default: |
||||
340 | return $stamp; |
||||
341 | break; |
||||
342 | } |
||||
343 | } |
||||
344 | |||||
345 | /** |
||||
346 | * Abstract method for building the children of a calendar object. |
||||
347 | * Implemented by Calendar subclasses. |
||||
348 | * |
||||
349 | * @param array $sDates array containing Calendar objects to select (optional) |
||||
350 | * |
||||
351 | * @return bool |
||||
352 | * @abstract |
||||
353 | */ |
||||
354 | public function build($sDates = []) |
||||
0 ignored issues
–
show
The parameter
$sDates is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
355 | { |
||||
356 | require_once __DIR__ . '/PEAR.php'; |
||||
357 | PEAR::raiseError('Calendar::build is abstract', null, PEAR_ERROR_TRIGGER, E_USER_NOTICE, 'Calendar::build()'); |
||||
0 ignored issues
–
show
The type
PEAR was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
358 | |||||
359 | return false; |
||||
360 | } |
||||
361 | |||||
362 | /** |
||||
363 | * Abstract method for selected data objects called from build. |
||||
364 | * |
||||
365 | * @param array $sDates array of Calendar objects to select |
||||
366 | * |
||||
367 | * @return bool |
||||
368 | * @abstract |
||||
369 | */ |
||||
370 | public function setSelection($sDates) |
||||
0 ignored issues
–
show
The parameter
$sDates is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
371 | { |
||||
372 | require_once __DIR__ . '/PEAR.php'; |
||||
373 | PEAR::raiseError('Calendar::setSelection is abstract', null, PEAR_ERROR_TRIGGER, E_USER_NOTICE, 'Calendar::setSelection()'); |
||||
0 ignored issues
–
show
|
|||||
374 | |||||
375 | return false; |
||||
376 | } |
||||
377 | |||||
378 | /** |
||||
379 | * Iterator method for fetching child Calendar subclass objects |
||||
380 | * (e.g. a minute from an hour object). On reaching the end of |
||||
381 | * the collection, returns false and resets the collection for |
||||
382 | * further iteratations. |
||||
383 | * |
||||
384 | * @return mixed either an object subclass of Calendar or false |
||||
385 | */ |
||||
386 | public function fetch() |
||||
387 | { |
||||
388 | // $child = each($this->children); |
||||
389 | $key = key($this->children); |
||||
390 | $child = (null === $key) ? false : [$key, current($this->children), 'key' => $key, 'value' => current($this->children)]; |
||||
391 | next($this->children); |
||||
392 | |||||
393 | if ($child) { |
||||
394 | return $child['value']; |
||||
395 | } |
||||
396 | reset($this->children); |
||||
397 | |||||
398 | return false; |
||||
399 | } |
||||
400 | |||||
401 | /** |
||||
402 | * Fetches all child from the current collection of children. |
||||
403 | * |
||||
404 | * @return array |
||||
405 | */ |
||||
406 | public function fetchAll() |
||||
407 | { |
||||
408 | return $this->children; |
||||
409 | } |
||||
410 | |||||
411 | /** |
||||
412 | * Get the number Calendar subclass objects stored in the internal collection. |
||||
413 | * |
||||
414 | * @return int |
||||
415 | */ |
||||
416 | public function size() |
||||
417 | { |
||||
418 | return count($this->children); |
||||
419 | } |
||||
420 | |||||
421 | /** |
||||
422 | * Determine whether this date is valid, with the bounds determined by |
||||
423 | * the Calendar_Engine. The call is passed on to Calendar_Validator::isValid. |
||||
424 | * |
||||
425 | * @return bool |
||||
426 | */ |
||||
427 | public function isValid() |
||||
428 | { |
||||
429 | $validator = $this->getValidator(); |
||||
430 | |||||
431 | return $validator->isValid(); |
||||
432 | } |
||||
433 | |||||
434 | /** |
||||
435 | * Returns an instance of Calendar_Validator. |
||||
436 | * |
||||
437 | * @return Calendar_Validator |
||||
438 | */ |
||||
439 | public function &getValidator() |
||||
440 | { |
||||
441 | if (!isset($this->validator)) { |
||||
442 | require_once CALENDAR_ROOT . 'Validator.php'; |
||||
443 | $this->validator = new Calendar_Validator($this); |
||||
444 | } |
||||
445 | |||||
446 | return $this->validator; |
||||
447 | } |
||||
448 | |||||
449 | /** |
||||
450 | * Returns a reference to the current Calendar_Engine being used. Useful |
||||
451 | * for Calendar_Table_Helper and Calendar_Validator. |
||||
452 | * |
||||
453 | * @return object implementing Calendar_Engine_Inteface |
||||
454 | */ |
||||
455 | public function &getEngine() |
||||
456 | { |
||||
457 | return $this->cE; |
||||
458 | } |
||||
459 | |||||
460 | /** |
||||
461 | * Set the CALENDAR_FIRST_DAY_OF_WEEK constant to the $firstDay value |
||||
462 | * if the constant is not set yet. |
||||
463 | * |
||||
464 | * @param int $firstDay first day of the week (0=sunday, 1=monday, ...) |
||||
465 | * |
||||
466 | * @return int |
||||
467 | * @throws E_USER_WARNING this method throws a WARNING if the |
||||
468 | * CALENDAR_FIRST_DAY_OF_WEEK constant is already defined and |
||||
469 | * the $firstDay parameter is set to a different value |
||||
470 | */ |
||||
471 | public function defineFirstDayOfWeek($firstDay = null) |
||||
472 | { |
||||
473 | if (defined('CALENDAR_FIRST_DAY_OF_WEEK')) { |
||||
474 | if ((CALENDAR_FIRST_DAY_OF_WEEK != $firstDay) && null !== $firstDay) { |
||||
475 | $msg = 'CALENDAR_FIRST_DAY_OF_WEEK constant already defined.' . ' The $firstDay parameter will be ignored.'; |
||||
476 | trigger_error($msg, E_USER_WARNING); |
||||
477 | } |
||||
478 | |||||
479 | return CALENDAR_FIRST_DAY_OF_WEEK; |
||||
480 | } |
||||
481 | if (null === $firstDay) { |
||||
482 | $firstDay = $this->cE->getFirstDayOfWeek($this->thisYear(), $this->thisMonth(), $this->thisDay()); |
||||
483 | } |
||||
484 | define('CALENDAR_FIRST_DAY_OF_WEEK', $firstDay); |
||||
485 | |||||
486 | return CALENDAR_FIRST_DAY_OF_WEEK; |
||||
487 | } |
||||
488 | |||||
489 | /** |
||||
490 | * Returns the value for the previous year. |
||||
491 | * |
||||
492 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||||
493 | * |
||||
494 | * @return int e.g. 2002 or timestamp |
||||
495 | */ |
||||
496 | public function prevYear($format = 'int') |
||||
497 | { |
||||
498 | $ts = $this->cE->dateToStamp($this->year - 1, 1, 1, 0, 0, 0); |
||||
499 | |||||
500 | return $this->returnValue('Year', $format, $ts, $this->year - 1); |
||||
0 ignored issues
–
show
|
|||||
501 | } |
||||
502 | |||||
503 | /** |
||||
504 | * Returns the value for this year. |
||||
505 | * |
||||
506 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||||
507 | * |
||||
508 | * @return int e.g. 2003 or timestamp |
||||
509 | */ |
||||
510 | public function thisYear($format = 'int') |
||||
511 | { |
||||
512 | $ts = $this->cE->dateToStamp($this->year, 1, 1, 0, 0, 0); |
||||
513 | |||||
514 | return $this->returnValue('Year', $format, $ts, $this->year); |
||||
0 ignored issues
–
show
|
|||||
515 | } |
||||
516 | |||||
517 | /** |
||||
518 | * Returns the value for next year. |
||||
519 | * |
||||
520 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||||
521 | * |
||||
522 | * @return int e.g. 2004 or timestamp |
||||
523 | */ |
||||
524 | public function nextYear($format = 'int') |
||||
525 | { |
||||
526 | $ts = $this->cE->dateToStamp($this->year + 1, 1, 1, 0, 0, 0); |
||||
527 | |||||
528 | return $this->returnValue('Year', $format, $ts, $this->year + 1); |
||||
0 ignored issues
–
show
|
|||||
529 | } |
||||
530 | |||||
531 | /** |
||||
532 | * Returns the value for the previous month. |
||||
533 | * |
||||
534 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||||
535 | * |
||||
536 | * @return int e.g. 4 or Unix timestamp |
||||
537 | */ |
||||
538 | public function prevMonth($format = 'int') |
||||
539 | { |
||||
540 | $ts = $this->cE->dateToStamp($this->year, $this->month - 1, 1, 0, 0, 0); |
||||
541 | |||||
542 | return $this->returnValue('Month', $format, $ts, $this->cE->stampToMonth($ts)); |
||||
0 ignored issues
–
show
|
|||||
543 | } |
||||
544 | |||||
545 | /** |
||||
546 | * Returns the value for this month. |
||||
547 | * |
||||
548 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||||
549 | * |
||||
550 | * @return int e.g. 5 or timestamp |
||||
551 | */ |
||||
552 | public function thisMonth($format = 'int') |
||||
553 | { |
||||
554 | $ts = $this->cE->dateToStamp($this->year, $this->month, 1, 0, 0, 0); |
||||
555 | |||||
556 | return $this->returnValue('Month', $format, $ts, $this->month); |
||||
0 ignored issues
–
show
|
|||||
557 | } |
||||
558 | |||||
559 | /** |
||||
560 | * Returns the value for next month. |
||||
561 | * |
||||
562 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||||
563 | * |
||||
564 | * @return int e.g. 6 or timestamp |
||||
565 | */ |
||||
566 | public function nextMonth($format = 'int') |
||||
567 | { |
||||
568 | $ts = $this->cE->dateToStamp($this->year, $this->month + 1, 1, 0, 0, 0); |
||||
569 | |||||
570 | return $this->returnValue('Month', $format, $ts, $this->cE->stampToMonth($ts)); |
||||
0 ignored issues
–
show
|
|||||
571 | } |
||||
572 | |||||
573 | /** |
||||
574 | * Returns the value for the previous day. |
||||
575 | * |
||||
576 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||||
577 | * |
||||
578 | * @return int e.g. 10 or timestamp |
||||
579 | */ |
||||
580 | public function prevDay($format = 'int') |
||||
581 | { |
||||
582 | $ts = $this->cE->dateToStamp($this->year, $this->month, $this->day - 1, 0, 0, 0); |
||||
583 | |||||
584 | return $this->returnValue('Day', $format, $ts, $this->cE->stampToDay($ts)); |
||||
0 ignored issues
–
show
|
|||||
585 | } |
||||
586 | |||||
587 | /** |
||||
588 | * Returns the value for this day. |
||||
589 | * |
||||
590 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||||
591 | * |
||||
592 | * @return int e.g. 11 or timestamp |
||||
593 | */ |
||||
594 | public function thisDay($format = 'int') |
||||
595 | { |
||||
596 | $ts = $this->cE->dateToStamp($this->year, $this->month, $this->day, 0, 0, 0); |
||||
597 | |||||
598 | return $this->returnValue('Day', $format, $ts, $this->day); |
||||
0 ignored issues
–
show
|
|||||
599 | } |
||||
600 | |||||
601 | /** |
||||
602 | * Returns the value for the next day. |
||||
603 | * |
||||
604 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||||
605 | * |
||||
606 | * @return int e.g. 12 or timestamp |
||||
607 | */ |
||||
608 | public function nextDay($format = 'int') |
||||
609 | { |
||||
610 | $ts = $this->cE->dateToStamp($this->year, $this->month, $this->day + 1, 0, 0, 0); |
||||
611 | |||||
612 | return $this->returnValue('Day', $format, $ts, $this->cE->stampToDay($ts)); |
||||
0 ignored issues
–
show
|
|||||
613 | } |
||||
614 | |||||
615 | /** |
||||
616 | * Returns the value for the previous hour. |
||||
617 | * |
||||
618 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||||
619 | * |
||||
620 | * @return int e.g. 13 or timestamp |
||||
621 | */ |
||||
622 | public function prevHour($format = 'int') |
||||
623 | { |
||||
624 | $ts = $this->cE->dateToStamp($this->year, $this->month, $this->day, $this->hour - 1, 0, 0); |
||||
625 | |||||
626 | return $this->returnValue('Hour', $format, $ts, $this->cE->stampToHour($ts)); |
||||
0 ignored issues
–
show
|
|||||
627 | } |
||||
628 | |||||
629 | /** |
||||
630 | * Returns the value for this hour. |
||||
631 | * |
||||
632 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||||
633 | * |
||||
634 | * @return int e.g. 14 or timestamp |
||||
635 | */ |
||||
636 | public function thisHour($format = 'int') |
||||
637 | { |
||||
638 | $ts = $this->cE->dateToStamp($this->year, $this->month, $this->day, $this->hour, 0, 0); |
||||
639 | |||||
640 | return $this->returnValue('Hour', $format, $ts, $this->hour); |
||||
0 ignored issues
–
show
|
|||||
641 | } |
||||
642 | |||||
643 | /** |
||||
644 | * Returns the value for the next hour. |
||||
645 | * |
||||
646 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||||
647 | * |
||||
648 | * @return int e.g. 14 or timestamp |
||||
649 | */ |
||||
650 | public function nextHour($format = 'int') |
||||
651 | { |
||||
652 | $ts = $this->cE->dateToStamp($this->year, $this->month, $this->day, $this->hour + 1, 0, 0); |
||||
653 | |||||
654 | return $this->returnValue('Hour', $format, $ts, $this->cE->stampToHour($ts)); |
||||
0 ignored issues
–
show
|
|||||
655 | } |
||||
656 | |||||
657 | /** |
||||
658 | * Returns the value for the previous minute. |
||||
659 | * |
||||
660 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||||
661 | * |
||||
662 | * @return int e.g. 23 or timestamp |
||||
663 | */ |
||||
664 | public function prevMinute($format = 'int') |
||||
665 | { |
||||
666 | $ts = $this->cE->dateToStamp($this->year, $this->month, $this->day, $this->hour, $this->minute - 1, 0); |
||||
667 | |||||
668 | return $this->returnValue('Minute', $format, $ts, $this->cE->stampToMinute($ts)); |
||||
0 ignored issues
–
show
|
|||||
669 | } |
||||
670 | |||||
671 | /** |
||||
672 | * Returns the value for this minute. |
||||
673 | * |
||||
674 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||||
675 | * |
||||
676 | * @return int e.g. 24 or timestamp |
||||
677 | */ |
||||
678 | public function thisMinute($format = 'int') |
||||
679 | { |
||||
680 | $ts = $this->cE->dateToStamp($this->year, $this->month, $this->day, $this->hour, $this->minute, 0); |
||||
681 | |||||
682 | return $this->returnValue('Minute', $format, $ts, $this->minute); |
||||
0 ignored issues
–
show
|
|||||
683 | } |
||||
684 | |||||
685 | /** |
||||
686 | * Returns the value for the next minute. |
||||
687 | * |
||||
688 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||||
689 | * |
||||
690 | * @return int e.g. 25 or timestamp |
||||
691 | */ |
||||
692 | public function nextMinute($format = 'int') |
||||
693 | { |
||||
694 | $ts = $this->cE->dateToStamp($this->year, $this->month, $this->day, $this->hour, $this->minute + 1, 0); |
||||
695 | |||||
696 | return $this->returnValue('Minute', $format, $ts, $this->cE->stampToMinute($ts)); |
||||
0 ignored issues
–
show
|
|||||
697 | } |
||||
698 | |||||
699 | /** |
||||
700 | * Returns the value for the previous second. |
||||
701 | * |
||||
702 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||||
703 | * |
||||
704 | * @return int e.g. 43 or timestamp |
||||
705 | */ |
||||
706 | public function prevSecond($format = 'int') |
||||
707 | { |
||||
708 | $ts = $this->cE->dateToStamp($this->year, $this->month, $this->day, $this->hour, $this->minute, $this->second - 1); |
||||
709 | |||||
710 | return $this->returnValue('Second', $format, $ts, $this->cE->stampToSecond($ts)); |
||||
0 ignored issues
–
show
|
|||||
711 | } |
||||
712 | |||||
713 | /** |
||||
714 | * Returns the value for this second. |
||||
715 | * |
||||
716 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||||
717 | * |
||||
718 | * @return int e.g. 44 or timestamp |
||||
719 | */ |
||||
720 | public function thisSecond($format = 'int') |
||||
721 | { |
||||
722 | $ts = $this->cE->dateToStamp($this->year, $this->month, $this->day, $this->hour, $this->minute, $this->second); |
||||
723 | |||||
724 | return $this->returnValue('Second', $format, $ts, $this->second); |
||||
0 ignored issues
–
show
|
|||||
725 | } |
||||
726 | |||||
727 | /** |
||||
728 | * Returns the value for the next second. |
||||
729 | * |
||||
730 | * @param string $format return value format ['int'|'timestamp'|'object'|'array'] |
||||
731 | * |
||||
732 | * @return int e.g. 45 or timestamp |
||||
733 | */ |
||||
734 | public function nextSecond($format = 'int') |
||||
735 | { |
||||
736 | $ts = $this->cE->dateToStamp($this->year, $this->month, $this->day, $this->hour, $this->minute, $this->second + 1); |
||||
737 | |||||
738 | return $this->returnValue('Second', $format, $ts, $this->cE->stampToSecond($ts)); |
||||
0 ignored issues
–
show
|
|||||
739 | } |
||||
740 | } |
||||
741 |
The
break
statement is not necessary if it is preceded for example by areturn
statement:If you would like to keep this construct to be consistent with other
case
statements, you can safely mark this issue as a false-positive.