Passed
Push — master ( d2520f...3f8ec2 )
by Michael
02:50
created

Calendar_Engine_PearDate::adjustDate()   F

Complexity

Conditions 13
Paths 2304

Size

Total Lines 47
Code Lines 34

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 47
rs 2.642
c 0
b 0
f 0
cc 13
eloc 34
nc 2304
nop 6

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 57 and the first side effect is on line 43.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
/* vim: set expandtab tabstop=4 shiftwidth=4: */
4
5
/**
6
 * Contains the Calendar_Engine_PearDate class.
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    Lorenzo Alberton <[email protected]>
34
 * @copyright 2003-2007 Lorenzo Alberton
35
 * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
36
 *
37
 * @link      http://pear.php.net/package/Calendar
38
 */
39
40
/**
41
 * Load PEAR::Date class.
42
 */
43
require_once __DIR__ . '/Date.php';
44
45
/**
46
 * Performs calendar calculations based on the PEAR::Date class
47
 * Timestamps are in the ISO-8601 format (YYYY-MM-DD HH:MM:SS).
48
 *
49
 * @category  Date and Time
50
 *
51
 * @author    Lorenzo Alberton <[email protected]>
52
 * @copyright 2003-2007 Lorenzo Alberton
53
 * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
54
 *
55
 * @link      http://pear.php.net/package/Calendar
56
 */
57
class Calendar_Engine_PearDate /* implements Calendar_Engine_Interface */
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
58
{
59
    /**
60
     * Makes sure a given timestamp is only ever parsed once
61
     * Uses a static variable to prevent date() being used twice
62
     * for a date which is already known.
63
     *
64
     * @param mixed $stamp Any timestamp format recognized by Pear::Date
65
     *
66
     * @return object Pear::Date object
67
     */
68
    public function stampCollection($stamp)
69
    {
70
        static $stamps = [];
71
        if (!isset($stamps[$stamp])) {
72
            $stamps[$stamp] = new Date($stamp);
73
        }
74
75
        return $stamps[$stamp];
76
    }
77
78
    /**
79
     * Returns a numeric year given a iso-8601 datetime.
80
     *
81
     * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
82
     *
83
     * @return int year (e.g. 2003)
84
     */
85
    public function stampToYear($stamp)
86
    {
87
        $date = self::stampCollection($stamp);
0 ignored issues
show
Bug Best Practice introduced by
The method Calendar_Engine_PearDate::stampCollection() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

87
        /** @scrutinizer ignore-call */ 
88
        $date = self::stampCollection($stamp);
Loading history...
88
89
        return (int)$date->year;
90
    }
91
92
    /**
93
     * Returns a numeric month given a iso-8601 datetime.
94
     *
95
     * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
96
     *
97
     * @return int month (e.g. 9)
98
     */
99
    public function stampToMonth($stamp)
100
    {
101
        $date = self::stampCollection($stamp);
0 ignored issues
show
Bug Best Practice introduced by
The method Calendar_Engine_PearDate::stampCollection() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

101
        /** @scrutinizer ignore-call */ 
102
        $date = self::stampCollection($stamp);
Loading history...
102
103
        return (int)$date->month;
104
    }
105
106
    /**
107
     * Returns a numeric day given a iso-8601 datetime.
108
     *
109
     * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
110
     *
111
     * @return int day (e.g. 15)
112
     */
113
    public function stampToDay($stamp)
114
    {
115
        $date = self::stampCollection($stamp);
0 ignored issues
show
Bug Best Practice introduced by
The method Calendar_Engine_PearDate::stampCollection() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

115
        /** @scrutinizer ignore-call */ 
116
        $date = self::stampCollection($stamp);
Loading history...
116
117
        return (int)$date->day;
118
    }
119
120
    /**
121
     * Returns a numeric hour given a iso-8601 datetime.
122
     *
123
     * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
124
     *
125
     * @return int hour (e.g. 13)
126
     */
127
    public function stampToHour($stamp)
128
    {
129
        $date = self::stampCollection($stamp);
0 ignored issues
show
Bug Best Practice introduced by
The method Calendar_Engine_PearDate::stampCollection() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

129
        /** @scrutinizer ignore-call */ 
130
        $date = self::stampCollection($stamp);
Loading history...
130
131
        return (int)$date->hour;
132
    }
133
134
    /**
135
     * Returns a numeric minute given a iso-8601 datetime.
136
     *
137
     * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
138
     *
139
     * @return int minute (e.g. 34)
140
     */
141
    public function stampToMinute($stamp)
142
    {
143
        $date = self::stampCollection($stamp);
0 ignored issues
show
Bug Best Practice introduced by
The method Calendar_Engine_PearDate::stampCollection() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

143
        /** @scrutinizer ignore-call */ 
144
        $date = self::stampCollection($stamp);
Loading history...
144
145
        return (int)$date->minute;
146
    }
147
148
    /**
149
     * Returns a numeric second given a iso-8601 datetime.
150
     *
151
     * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
152
     *
153
     * @return int second (e.g. 51)
154
     */
155
    public function stampToSecond($stamp)
156
    {
157
        $date = self::stampCollection($stamp);
0 ignored issues
show
Bug Best Practice introduced by
The method Calendar_Engine_PearDate::stampCollection() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

157
        /** @scrutinizer ignore-call */ 
158
        $date = self::stampCollection($stamp);
Loading history...
158
159
        return (int)$date->second;
160
    }
161
162
    /**
163
     * Returns a iso-8601 datetime.
164
     *
165
     * @param int $y year (2003)
166
     * @param int $m month (9)
167
     * @param int $d day (13)
168
     * @param int $h hour (13)
169
     * @param int $i minute (34)
170
     * @param int $s second (53)
171
     *
172
     * @return string iso-8601 datetime
173
     */
174
    public function dateToStamp($y, $m, $d, $h = 0, $i = 0, $s = 0)
175
    {
176
        $r = [];
177
        self::adjustDate($y, $m, $d, $h, $i, $s);
0 ignored issues
show
Bug Best Practice introduced by
The method Calendar_Engine_PearDate::adjustDate() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

177
        self::/** @scrutinizer ignore-call */ 
178
              adjustDate($y, $m, $d, $h, $i, $s);
Loading history...
178
        $key = $y . $m . $d . $h . $i . $s;
179
        if (!isset($r[$key])) {
180
            $r[$key] = sprintf('%04d-%02d-%02d %02d:%02d:%02d', $y, $m, $d, $h, $i, $s);
181
        }
182
183
        return $r[$key];
184
    }
185
186
    /**
187
     * Set the correct date values (useful for math operations on dates).
188
     *
189
     * @param int &$y year   (2003)
190
     * @param int &$m month  (9)
191
     * @param int &$d day    (13)
192
     * @param int &$h hour   (13)
193
     * @param int &$i minute (34)
194
     * @param int &$s second (53)
195
     */
196
    public function adjustDate(&$y, &$m, &$d, &$h, &$i, &$s)
197
    {
198
        if ($s < 0) {
199
            $m -= floor($s / _EXTCAL_TS_MINUTE);
200
            $s = -$s % _EXTCAL_TS_MINUTE;
201
        }
202
        if ($s > _EXTCAL_TS_MINUTE) {
203
            $m += floor($s / _EXTCAL_TS_MINUTE);
204
            $s %= _EXTCAL_TS_MINUTE;
205
        }
206
        if ($i < 0) {
207
            $h -= floor($i / _EXTCAL_TS_MINUTE);
208
            $i = -$i % _EXTCAL_TS_MINUTE;
209
        }
210
        if ($i > _EXTCAL_TS_MINUTE) {
211
            $h += floor($i / _EXTCAL_TS_MINUTE);
212
            $i %= _EXTCAL_TS_MINUTE;
213
        }
214
        if ($h < 0) {
215
            $d -= floor($h / 24);
216
            $h = -$h % 24;
217
        }
218
        if ($h > 24) {
219
            $d += floor($h / 24);
220
            $h %= 24;
221
        }
222
        for (; $m < 1; $y--, $m += 12) {
0 ignored issues
show
Unused Code introduced by
This for loop is empty and can be removed.

This check looks for for loops that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

Consider removing the loop.

Loading history...
223
        }
224
        for (; $m > 12; $y++, $m -= 12) {
0 ignored issues
show
Unused Code introduced by
This for loop is empty and can be removed.

This check looks for for loops that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

Consider removing the loop.

Loading history...
225
        }
226
227
        while ($d < 1) {
228
            if ($m > 1) {
229
                --$m;
230
            } else {
231
                $m = 12;
232
                --$y;
233
            }
234
            $d += Date_Calc::daysInMonth($m, $y);
0 ignored issues
show
Bug introduced by
The type Date_Calc 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
235
        }
236
        for ($max_days = Date_Calc::daysInMonth($m, $y); $d > $max_days;) {
237
            $d -= $max_days;
238
            if ($m < 12) {
239
                ++$m;
240
            } else {
241
                $m = 1;
242
                ++$y;
243
            }
244
        }
245
    }
246
247
    /**
248
     * The upper limit on years that the Calendar Engine can work with.
249
     *
250
     * @return int 9999
251
     */
252
    public function getMaxYears()
253
    {
254
        return 9999;
255
    }
256
257
    /**
258
     * The lower limit on years that the Calendar Engine can work with.
259
     *
260
     * @return int
261
     */
262
    public function getMinYears()
263
    {
264
        return 0;
265
    }
266
267
    /**
268
     * Returns the number of months in a year.
269
     *
270
     * @param int $y year
271
     *
272
     * @return int (12)
273
     */
274
    public function getMonthsInYear($y = null)
0 ignored issues
show
Unused Code introduced by
The parameter $y 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 ignore-unused  annotation

274
    public function getMonthsInYear(/** @scrutinizer ignore-unused */ $y = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
275
    {
276
        return 12;
277
    }
278
279
    /**
280
     * Returns the number of days in a month, given year and month.
281
     *
282
     * @param int $y year (2003)
283
     * @param int $m month (9)
284
     *
285
     * @return int days in month
286
     */
287
    public function getDaysInMonth($y, $m)
288
    {
289
        return (int)Date_Calc::daysInMonth($m, $y);
290
    }
291
292
    /**
293
     * Returns numeric representation of the day of the week in a month,
294
     * given year and month.
295
     *
296
     * @param int $y year (2003)
297
     * @param int $m month (9)
298
     *
299
     * @return int from 0 to 7
300
     */
301
    public function getFirstDayInMonth($y, $m)
302
    {
303
        return (int)Date_Calc::dayOfWeek(1, $m, $y);
304
    }
305
306
    /**
307
     * Returns the number of days in a week.
308
     *
309
     * @param int $y year (2003)
310
     * @param int $m month (9)
311
     * @param int $d day (4)
312
     *
313
     * @return int (7)
314
     */
315
    public function getDaysInWeek($y = null, $m = null, $d = null)
0 ignored issues
show
Unused Code introduced by
The parameter $y 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 ignore-unused  annotation

315
    public function getDaysInWeek(/** @scrutinizer ignore-unused */ $y = null, $m = null, $d = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $m 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 ignore-unused  annotation

315
    public function getDaysInWeek($y = null, /** @scrutinizer ignore-unused */ $m = null, $d = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $d 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 ignore-unused  annotation

315
    public function getDaysInWeek($y = null, $m = null, /** @scrutinizer ignore-unused */ $d = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
316
    {
317
        return 7;
318
    }
319
320
    /**
321
     * Returns the number of the week in the year (ISO-8601), given a date.
322
     *
323
     * @param int $y year (2003)
324
     * @param int $m month (9)
325
     * @param int $d day (4)
326
     *
327
     * @return int week number
328
     */
329
    public function getWeekNInYear($y, $m, $d)
330
    {
331
        //return Date_Calc::weekOfYear($d, $m, $y); //beware, Date_Calc doesn't follow ISO-8601 standard!
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
332
        list($nYear, $nWeek) = Date_Calc::weekOfYear4th($d, $m, $y);
333
334
        return $nWeek;
335
    }
336
337
    /**
338
     * Returns the number of the week in the month, given a date.
339
     *
340
     * @param int $y        year (2003)
341
     * @param int $m        month (9)
342
     * @param int $d        day (4)
343
     * @param int $firstDay first day of the week (default: monday)
344
     *
345
     * @return int week number
346
     */
347
    public function getWeekNInMonth($y, $m, $d, $firstDay = 1)
348
    {
349
        $weekEnd     = (0 == $firstDay) ? $this->getDaysInWeek() - 1 : $firstDay - 1;
350
        $end_of_week = (int)Date_Calc::nextDayOfWeek($weekEnd, 1, $m, $y, '%e', true);
351
        $w           = 1;
352
        while ($d > $end_of_week) {
353
            ++$w;
354
            $end_of_week += $this->getDaysInWeek();
355
        }
356
357
        return $w;
358
    }
359
360
    /**
361
     * Returns the number of weeks in the month.
362
     *
363
     * @param int $y        year (2003)
364
     * @param int $m        month (9)
365
     * @param int $firstDay first day of the week (default: monday)
366
     *
367
     * @return int weeks number
368
     */
369
    public function getWeeksInMonth($y, $m, $firstDay = 1)
370
    {
371
        $FDOM = Date_Calc::firstOfMonthWeekday($m, $y);
372
        if (0 == $FDOM) {
373
            $FDOM = $this->getDaysInWeek();
374
        }
375
        if ($FDOM > $firstDay) {
376
            $daysInTheFirstWeek = $this->getDaysInWeek() - $FDOM + $firstDay;
377
            $weeks              = 1;
378
        } else {
379
            $daysInTheFirstWeek = $firstDay - $FDOM;
380
            $weeks              = 0;
381
        }
382
        $daysInTheFirstWeek %= $this->getDaysInWeek();
383
384
        return (int)(ceil(($this->getDaysInMonth($y, $m) - $daysInTheFirstWeek) / $this->getDaysInWeek()) + $weeks);
385
    }
386
387
    /**
388
     * Returns the number of the day of the week (0=sunday, 1=monday...).
389
     *
390
     * @param int $y year (2003)
391
     * @param int $m month (9)
392
     * @param int $d day (4)
393
     *
394
     * @return int weekday number
395
     */
396
    public function getDayOfWeek($y, $m, $d)
397
    {
398
        return Date_Calc::dayOfWeek($d, $m, $y);
399
    }
400
401
    /**
402
     * Returns a list of integer days of the week beginning 0.
403
     *
404
     * @param int $y year (2003)
405
     * @param int $m month (9)
406
     * @param int $d day (4)
407
     *
408
     * @return array (0, 1, 2, 3, 4, 5, 6) 1 = Monday
409
     */
410
    public function getWeekDays($y = null, $m = null, $d = null)
0 ignored issues
show
Unused Code introduced by
The parameter $d 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 ignore-unused  annotation

410
    public function getWeekDays($y = null, $m = null, /** @scrutinizer ignore-unused */ $d = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $m 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 ignore-unused  annotation

410
    public function getWeekDays($y = null, /** @scrutinizer ignore-unused */ $m = null, $d = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $y 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 ignore-unused  annotation

410
    public function getWeekDays(/** @scrutinizer ignore-unused */ $y = null, $m = null, $d = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
411
    {
412
        return [0, 1, 2, 3, 4, 5, 6];
413
    }
414
415
    /**
416
     * Returns the default first day of the week.
417
     *
418
     * @param int $y year (2003)
419
     * @param int $m month (9)
420
     * @param int $d day (4)
421
     *
422
     * @return int (default 1 = Monday)
423
     */
424
    public function getFirstDayOfWeek($y = null, $m = null, $d = null)
0 ignored issues
show
Unused Code introduced by
The parameter $m 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 ignore-unused  annotation

424
    public function getFirstDayOfWeek($y = null, /** @scrutinizer ignore-unused */ $m = null, $d = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $y 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 ignore-unused  annotation

424
    public function getFirstDayOfWeek(/** @scrutinizer ignore-unused */ $y = null, $m = null, $d = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $d 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 ignore-unused  annotation

424
    public function getFirstDayOfWeek($y = null, $m = null, /** @scrutinizer ignore-unused */ $d = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
425
    {
426
        return 1;
427
    }
428
429
    /**
430
     * Returns the number of hours in a day.
431
     *
432
     * @param int $y year (2003)
433
     * @param int $m month (9)
434
     * @param int $d day (4)
435
     *
436
     * @return int (24)
437
     */
438
    public function getHoursInDay($y = null, $m = null, $d = null)
0 ignored issues
show
Unused Code introduced by
The parameter $d 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 ignore-unused  annotation

438
    public function getHoursInDay($y = null, $m = null, /** @scrutinizer ignore-unused */ $d = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $y 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 ignore-unused  annotation

438
    public function getHoursInDay(/** @scrutinizer ignore-unused */ $y = null, $m = null, $d = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $m 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 ignore-unused  annotation

438
    public function getHoursInDay($y = null, /** @scrutinizer ignore-unused */ $m = null, $d = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
439
    {
440
        return 24;
441
    }
442
443
    /**
444
     * Returns the number of minutes in an hour.
445
     *
446
     * @param int $y year (2003)
447
     * @param int $m month (9)
448
     * @param int $d day (4)
449
     * @param int $h hour
450
     *
451
     * @return int (_EXTCAL_TS_MINUTE)
452
     */
453
    public function getMinutesInHour($y = null, $m = null, $d = null, $h = null)
0 ignored issues
show
Unused Code introduced by
The parameter $d 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 ignore-unused  annotation

453
    public function getMinutesInHour($y = null, $m = null, /** @scrutinizer ignore-unused */ $d = null, $h = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $m 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 ignore-unused  annotation

453
    public function getMinutesInHour($y = null, /** @scrutinizer ignore-unused */ $m = null, $d = null, $h = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $h 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 ignore-unused  annotation

453
    public function getMinutesInHour($y = null, $m = null, $d = null, /** @scrutinizer ignore-unused */ $h = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $y 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 ignore-unused  annotation

453
    public function getMinutesInHour(/** @scrutinizer ignore-unused */ $y = null, $m = null, $d = null, $h = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
454
    {
455
        return _EXTCAL_TS_MINUTE;
456
    }
457
458
    /**
459
     * Returns the number of seconds in a minutes.
460
     *
461
     * @param int $y year (2003)
462
     * @param int $m month (9)
463
     * @param int $d day (4)
464
     * @param int $h hour
465
     * @param int $i minute
466
     *
467
     * @return int (_EXTCAL_TS_MINUTE)
468
     */
469
    public function getSecondsInMinute($y = null, $m = null, $d = null, $h = null, $i = null)
0 ignored issues
show
Unused Code introduced by
The parameter $i 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 ignore-unused  annotation

469
    public function getSecondsInMinute($y = null, $m = null, $d = null, $h = null, /** @scrutinizer ignore-unused */ $i = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $h 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 ignore-unused  annotation

469
    public function getSecondsInMinute($y = null, $m = null, $d = null, /** @scrutinizer ignore-unused */ $h = null, $i = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $y 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 ignore-unused  annotation

469
    public function getSecondsInMinute(/** @scrutinizer ignore-unused */ $y = null, $m = null, $d = null, $h = null, $i = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $m 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 ignore-unused  annotation

469
    public function getSecondsInMinute($y = null, /** @scrutinizer ignore-unused */ $m = null, $d = null, $h = null, $i = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $d 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 ignore-unused  annotation

469
    public function getSecondsInMinute($y = null, $m = null, /** @scrutinizer ignore-unused */ $d = null, $h = null, $i = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
470
    {
471
        return _EXTCAL_TS_MINUTE;
472
    }
473
474
    /**
475
     * Checks if the given day is the current day.
476
     *
477
     * @param mixed $stamp Any timestamp format recognized by Pear::Date
478
     *
479
     * @return bool
480
     */
481
    public function isToday($stamp)
482
    {
483
        static $today = null;
484
        if (is_null($today)) {
485
            $today = new Date();
486
        }
487
        $date = self::stampCollection($stamp);
0 ignored issues
show
Bug Best Practice introduced by
The method Calendar_Engine_PearDate::stampCollection() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

487
        /** @scrutinizer ignore-call */ 
488
        $date = self::stampCollection($stamp);
Loading history...
488
489
        return $date->day == $today->getDay() && $date->month == $today->getMonth()
490
               && $date->year == $today->getYear();
491
    }
492
}
493