Passed
Pull Request — master (#2)
by tsms
01:30
created

PearDate::adjustDate()   F

Complexity

Conditions 13
Paths 2304

Size

Total Lines 45
Code Lines 34

Duplication

Lines 0
Ratio 0 %

Importance

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

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
2
/* vim: set expandtab tabstop=4 shiftwidth=4: */
3
4
/**
5
 * Contains the Calendar_Engine_PearDate class
6
 *
7
 * PHP versions 4 and 5
8
 *
9
 * LICENSE: Redistribution and use in source and binary forms, with or without
10
 * modification, are permitted provided that the following conditions are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice, this list of conditions and the following disclaimer.
13
 * 2. Redistributions in binary form must reproduce the above copyright
14
 *    notice, this list of conditions and the following disclaimer in the
15
 *    documentation and/or other materials provided with the distribution.
16
 * 3. The name of the author may not be used to endorse or promote products
17
 *    derived from this software without specific prior written permission.
18
 *
19
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
20
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
 * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
23
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 *
30
 * @category  Date and Time
31
 * @package   Calendar
32
 * @author    Lorenzo Alberton <[email protected]>
33
 * @copyright 2003-2007 Lorenzo Alberton
34
 * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
35
 * @version   CVS: $Id$
36
 * @link      http://pear.php.net/package/Calendar
37
 */
38
namespace Pear\Calendar\Engine;
39
40
/**
41
 * Performs calendar calculations based on the PEAR::Date class
42
 * Timestamps are in the ISO-8601 format (YYYY-MM-DD HH:MM:SS)
43
 *
44
 * @category  Date and Time
45
 * @package   Calendar
46
 * @author    Lorenzo Alberton <[email protected]>
47
 * @copyright 2003-2007 Lorenzo Alberton
48
 * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
49
 * @link      http://pear.php.net/package/Calendar
50
 * @access protected
51
 */
52
class PearDate /* implements Calendar_Engine_Interface */
53
{
54
    /**
55
     * Makes sure a given timestamp is only ever parsed once
56
     * Uses a static variable to prevent date() being used twice
57
     * for a date which is already known
58
     *
59
     * @param mixed $stamp Any timestamp format recognized by Pear::Date
60
     *
61
     * @return object Pear::Date object
62
     * @access protected
63
     */
64
    function stampCollection($stamp)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
65
    {
66
        static $stamps = array();
67
        if (!isset($stamps[$stamp])) {
68
            $stamps[$stamp] = new Date($stamp);
0 ignored issues
show
Bug introduced by
The type Pear\Calendar\Engine\Date 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...
69
        }
70
        return $stamps[$stamp];
71
    }
72
73
    /**
74
     * Returns a numeric year given a iso-8601 datetime
75
     *
76
     * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
77
     *
78
     * @return int year (e.g. 2003)
79
     * @access protected
80
     */
81
    function stampToYear($stamp)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
82
    {
83
        $date = PearDate::stampCollection($stamp);
0 ignored issues
show
Bug Best Practice introduced by
The method Pear\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

83
        /** @scrutinizer ignore-call */ 
84
        $date = PearDate::stampCollection($stamp);
Loading history...
84
        return (int)$date->year;
85
    }
86
87
    /**
88
     * Returns a numeric month given a iso-8601 datetime
89
     *
90
     * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
91
     *
92
     * @return int month (e.g. 9)
93
     * @access protected
94
     */
95
    function stampToMonth($stamp)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
96
    {
97
        $date = PearDate::stampCollection($stamp);
0 ignored issues
show
Bug Best Practice introduced by
The method Pear\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

97
        /** @scrutinizer ignore-call */ 
98
        $date = PearDate::stampCollection($stamp);
Loading history...
98
        return (int)$date->month;
99
    }
100
101
    /**
102
     * Returns a numeric day given a iso-8601 datetime
103
     *
104
     * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
105
     *
106
     * @return int day (e.g. 15)
107
     * @access protected
108
     */
109
    function stampToDay($stamp)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
110
    {
111
        $date = PearDate::stampCollection($stamp);
0 ignored issues
show
Bug Best Practice introduced by
The method Pear\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

111
        /** @scrutinizer ignore-call */ 
112
        $date = PearDate::stampCollection($stamp);
Loading history...
112
        return (int)$date->day;
113
    }
114
115
    /**
116
     * Returns a numeric hour given a iso-8601 datetime
117
     *
118
     * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
119
     *
120
     * @return int hour (e.g. 13)
121
     * @access protected
122
     */
123
    function stampToHour($stamp)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
124
    {
125
        $date = PearDate::stampCollection($stamp);
0 ignored issues
show
Bug Best Practice introduced by
The method Pear\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

125
        /** @scrutinizer ignore-call */ 
126
        $date = PearDate::stampCollection($stamp);
Loading history...
126
        return (int)$date->hour;
127
    }
128
129
    /**
130
     * Returns a numeric minute given a iso-8601 datetime
131
     *
132
     * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
133
     *
134
     * @return int minute (e.g. 34)
135
     * @access protected
136
     */
137
    function stampToMinute($stamp)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
138
    {
139
        $date = PearDate::stampCollection($stamp);
0 ignored issues
show
Bug Best Practice introduced by
The method Pear\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

139
        /** @scrutinizer ignore-call */ 
140
        $date = PearDate::stampCollection($stamp);
Loading history...
140
        return (int)$date->minute;
141
    }
142
143
    /**
144
     * Returns a numeric second given a iso-8601 datetime
145
     *
146
     * @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
147
     *
148
     * @return int second (e.g. 51)
149
     * @access protected
150
     */
151
    function stampToSecond($stamp)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
152
    {
153
        $date = PearDate::stampCollection($stamp);
0 ignored issues
show
Bug Best Practice introduced by
The method Pear\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

153
        /** @scrutinizer ignore-call */ 
154
        $date = PearDate::stampCollection($stamp);
Loading history...
154
        return (int)$date->second;
155
    }
156
157
    /**
158
     * Returns a iso-8601 datetime
159
     *
160
     * @param int $y year (2003)
161
     * @param int $m month (9)
162
     * @param int $d day (13)
163
     * @param int $h hour (13)
164
     * @param int $i minute (34)
165
     * @param int $s second (53)
166
     *
167
     * @return string iso-8601 datetime
168
     * @access protected
169
     */
170
    function dateToStamp($y, $m, $d, $h=0, $i=0, $s=0)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
171
    {
172
        $r = array();
173
        PearDate::adjustDate($y, $m, $d, $h, $i, $s);
0 ignored issues
show
Bug Best Practice introduced by
The method Pear\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

173
        PearDate::/** @scrutinizer ignore-call */ 
174
                  adjustDate($y, $m, $d, $h, $i, $s);
Loading history...
174
        $key = $y.$m.$d.$h.$i.$s;
175
        if (!isset($r[$key])) {
176
            $r[$key] = sprintf("%04d-%02d-%02d %02d:%02d:%02d",
177
                                $y, $m, $d, $h, $i, $s);
178
        }
179
        return $r[$key];
180
    }
181
182
    /**
183
     * Set the correct date values (useful for math operations on dates)
184
     *
185
     * @param int &$y year   (2003)
186
     * @param int &$m month  (9)
187
     * @param int &$d day    (13)
188
     * @param int &$h hour   (13)
189
     * @param int &$i minute (34)
190
     * @param int &$s second (53)
191
     *
192
     * @return void
193
     * @access protected
194
     */
195
    function adjustDate(&$y, &$m, &$d, &$h, &$i, &$s)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
196
    {
197
        if ($s < 0) {
198
            $m -= floor($s / 60);
199
            $s = -$s % 60;
200
        }
201
        if ($s > 60) {
202
            $m += floor($s / 60);
203
            $s %= 60;
204
        }
205
        if ($i < 0) {
206
            $h -= floor($i / 60);
207
            $i = -$i % 60;
208
        }
209
        if ($i > 60) {
210
            $h += floor($i / 60);
211
            $i %= 60;
212
        }
213
        if ($h < 0) {
214
            $d -= floor($h / 24);
215
            $h = -$h % 24;
216
        }
217
        if ($h > 24) {
218
            $d += floor($h / 24);
219
            $h %= 24;
220
        }
221
        for(; $m < 1; $y--, $m+=12);
222
        for(; $m > 12; $y++, $m-=12);
223
224
        while ($d < 1) {
225
            if ($m > 1) {
226
                $m--;
227
            } else {
228
                $m = 12;
229
                $y--;
230
            }
231
            $d += Date_Calc::daysInMonth($m, $y);
0 ignored issues
show
Bug introduced by
The type Pear\Calendar\Engine\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...
232
        }
233
        for ($max_days = Date_Calc::daysInMonth($m, $y); $d > $max_days; ) {
234
            $d -= $max_days;
235
            if ($m < 12) {
236
                $m++;
237
            } else {
238
                $m = 1;
239
                $y++;
240
            }
241
        }
242
    }
243
244
    /**
245
     * The upper limit on years that the Calendar Engine can work with
246
     *
247
     * @return int 9999
248
     * @access protected
249
     */
250
    function getMaxYears()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
251
    {
252
        return 9999;
253
    }
254
255
    /**
256
     * The lower limit on years that the Calendar Engine can work with
257
     *
258
     * @return int 0
259
     * @access protected
260
     */
261
    function getMinYears()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
262
    {
263
        return 0;
264
    }
265
266
    /**
267
     * Returns the number of months in a year
268
     *
269
     * @param int $y year
270
     *
271
     * @return int (12)
272
     * @access protected
273
     */
274
    function getMonthsInYear($y=null)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

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

274
    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
     * @access protected
287
     */
288
    function getDaysInMonth($y, $m)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
289
    {
290
        return (int)Date_Calc::daysInMonth($m, $y);
291
    }
292
293
    /**
294
     * Returns numeric representation of the day of the week in a month,
295
     * given year and month
296
     *
297
     * @param int $y year (2003)
298
     * @param int $m month (9)
299
     *
300
     * @return int from 0 to 7
301
     * @access protected
302
     */
303
    function getFirstDayInMonth($y, $m)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
304
    {
305
        return (int)Date_Calc::dayOfWeek(1, $m, $y);
306
    }
307
308
    /**
309
     * Returns the number of days in a week
310
     *
311
     * @param int $y year (2003)
312
     * @param int $m month (9)
313
     * @param int $d day (4)
314
     *
315
     * @return int (7)
316
     * @access protected
317
     */
318
    function getDaysInWeek($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

318
    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...
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

318
    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...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

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

318
    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...
319
    {
320
        return 7;
321
    }
322
323
    /**
324
     * Returns the number of the week in the year (ISO-8601), given a date
325
     *
326
     * @param int $y year (2003)
327
     * @param int $m month (9)
328
     * @param int $d day (4)
329
     *
330
     * @return int week number
331
     * @access protected
332
     */
333
    function getWeekNInYear($y, $m, $d)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
334
    {
335
        //return Date_Calc::weekOfYear($d, $m, $y); //beware, Date_Calc doesn't follow ISO-8601 standard!
336
        list($nYear, $nWeek) = Date_Calc::weekOfYear4th($d, $m, $y);
337
        return $nWeek;
338
    }
339
340
    /**
341
     * Returns the number of the week in the month, given a date
342
     *
343
     * @param int $y        year (2003)
344
     * @param int $m        month (9)
345
     * @param int $d        day (4)
346
     * @param int $firstDay first day of the week (default: monday)
347
     *
348
     * @return int week number
349
     * @access protected
350
     */
351
    function getWeekNInMonth($y, $m, $d, $firstDay=1)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
352
    {
353
        $weekEnd = ($firstDay == 0) ? $this->getDaysInWeek()-1 : $firstDay-1;
354
        $end_of_week = (int)Date_Calc::nextDayOfWeek($weekEnd, 1, $m, $y, '%e', true);
355
        $w = 1;
356
        while ($d > $end_of_week) {
357
            ++$w;
358
            $end_of_week += $this->getDaysInWeek();
359
        }
360
        return $w;
361
    }
362
363
    /**
364
     * Returns the number of weeks in the month
365
     *
366
     * @param int $y        year (2003)
367
     * @param int $m        month (9)
368
     * @param int $firstDay first day of the week (default: monday)
369
     *
370
     * @return int weeks number
371
     * @access protected
372
     */
373
    function getWeeksInMonth($y, $m, $firstDay=1)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
374
    {
375
        $FDOM = Date_Calc::firstOfMonthWeekday($m, $y);
376
        if ($FDOM == 0) {
377
            $FDOM = $this->getDaysInWeek();
378
        }
379
        if ($FDOM > $firstDay) {
380
            $daysInTheFirstWeek = $this->getDaysInWeek() - $FDOM + $firstDay;
381
            $weeks = 1;
382
        } else {
383
            $daysInTheFirstWeek = $firstDay - $FDOM;
384
            $weeks = 0;
385
        }
386
        $daysInTheFirstWeek %= $this->getDaysInWeek();
387
        return (int)(ceil(($this->getDaysInMonth($y, $m) - $daysInTheFirstWeek) /
388
                           $this->getDaysInWeek()) + $weeks);
389
    }
390
391
    /**
392
     * Returns the number of the day of the week (0=sunday, 1=monday...)
393
     *
394
     * @param int $y year (2003)
395
     * @param int $m month (9)
396
     * @param int $d day (4)
397
     *
398
     * @return int weekday number
399
     * @access protected
400
     */
401
    function getDayOfWeek($y, $m, $d)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
402
    {
403
        return Date_Calc::dayOfWeek($d, $m, $y);
404
    }
405
406
    /**
407
     * Returns a list of integer days of the week beginning 0
408
     *
409
     * @param int $y year (2003)
410
     * @param int $m month (9)
411
     * @param int $d day (4)
412
     *
413
     * @return array (0, 1, 2, 3, 4, 5, 6) 1 = Monday
414
     * @access protected
415
     */
416
    function getWeekDays($y=null, $m=null, $d=null)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

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

416
    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 $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

416
    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 $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

416
    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...
417
    {
418
        return array(0, 1, 2, 3, 4, 5, 6);
419
    }
420
421
    /**
422
     * Returns the default first day of the week
423
     *
424
     * @param int $y year (2003)
425
     * @param int $m month (9)
426
     * @param int $d day (4)
427
     *
428
     * @return int (default 1 = Monday)
429
     * @access protected
430
     */
431
    function getFirstDayOfWeek($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

431
    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...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

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

431
    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 $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

431
    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...
432
    {
433
        return 1;
434
    }
435
436
    /**
437
     * Returns the number of hours in a day
438
     *
439
     * @param int $y year (2003)
440
     * @param int $m month (9)
441
     * @param int $d day (4)
442
     *
443
     * @return int (24)
444
     * @access protected
445
     */
446
    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

446
    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

446
    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...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

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

446
    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...
447
    {
448
        return 24;
449
    }
450
451
    /**
452
     * Returns the number of minutes in an hour
453
     *
454
     * @param int $y year (2003)
455
     * @param int $m month (9)
456
     * @param int $d day (4)
457
     * @param int $h hour
458
     *
459
     * @return int (60)
460
     * @access protected
461
     */
462
    function getMinutesInHour($y=null,$m=null,$d=null,$h=null)
0 ignored issues
show
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

462
    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...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

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

462
    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 $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

462
    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 $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

462
    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...
463
    {
464
        return 60;
465
    }
466
467
    /**
468
     * Returns the number of seconds in a minutes
469
     *
470
     * @param int $y year (2003)
471
     * @param int $m month (9)
472
     * @param int $d day (4)
473
     * @param int $h hour
474
     * @param int $i minute
475
     *
476
     * @return int (60)
477
     * @access protected
478
     */
479
    function getSecondsInMinute($y=null,$m=null,$d=null,$h=null,$i=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

479
    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...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

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

479
    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 $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

479
    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

479
    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 $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

479
    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...
480
    {
481
        return 60;
482
    }
483
484
    /**
485
     * Checks if the given day is the current day
486
     *
487
     * @param mixed $stamp Any timestamp format recognized by Pear::Date
488
     *
489
     * @return boolean
490
     * @access protected
491
     */
492
    function isToday($stamp)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
493
    {
494
        static $today = null;
495
        if (is_null($today)) {
496
            $today = new Date();
497
        }
498
        $date = PearDate::stampCollection($stamp);
0 ignored issues
show
Bug Best Practice introduced by
The method Pear\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

498
        /** @scrutinizer ignore-call */ 
499
        $date = PearDate::stampCollection($stamp);
Loading history...
499
        return (   $date->day == $today->getDay()
500
                && $date->month == $today->getMonth()
501
                && $date->year == $today->getYear()
502
        );
503
    }
504
}
505