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

Calendar_Engine_PearDate::stampToYear()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
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
 * Load PEAR::Date class
42
 */
43
require_once '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
 * @package   Calendar
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
 * @link      http://pear.php.net/package/Calendar
55
 * @access protected
56
 */
57
class Calendar_Engine_PearDate /* implements Calendar_Engine_Interface */
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
     * @access protected
68
     */
69
    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...
70
    {
71
        static $stamps = array();
72
        if (!isset($stamps[$stamp])) {
73
            $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...
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
     * @access protected
85
     */
86
    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...
87
    {
88
        $date = Calendar_Engine_PearDate::stampCollection($stamp);
0 ignored issues
show
Bug Best Practice introduced by
The method Pear\Calendar\Engine\Cal...Date::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

88
        /** @scrutinizer ignore-call */ 
89
        $date = Calendar_Engine_PearDate::stampCollection($stamp);
Loading history...
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
     * @access protected
99
     */
100
    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...
101
    {
102
        $date = Calendar_Engine_PearDate::stampCollection($stamp);
0 ignored issues
show
Bug Best Practice introduced by
The method Pear\Calendar\Engine\Cal...Date::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

102
        /** @scrutinizer ignore-call */ 
103
        $date = Calendar_Engine_PearDate::stampCollection($stamp);
Loading history...
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
     * @access protected
113
     */
114
    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...
115
    {
116
        $date = Calendar_Engine_PearDate::stampCollection($stamp);
0 ignored issues
show
Bug Best Practice introduced by
The method Pear\Calendar\Engine\Cal...Date::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

116
        /** @scrutinizer ignore-call */ 
117
        $date = Calendar_Engine_PearDate::stampCollection($stamp);
Loading history...
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
     * @access protected
127
     */
128
    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...
129
    {
130
        $date = Calendar_Engine_PearDate::stampCollection($stamp);
0 ignored issues
show
Bug Best Practice introduced by
The method Pear\Calendar\Engine\Cal...Date::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

130
        /** @scrutinizer ignore-call */ 
131
        $date = Calendar_Engine_PearDate::stampCollection($stamp);
Loading history...
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
     * @access protected
141
     */
142
    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...
143
    {
144
        $date = Calendar_Engine_PearDate::stampCollection($stamp);
0 ignored issues
show
Bug Best Practice introduced by
The method Pear\Calendar\Engine\Cal...Date::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

144
        /** @scrutinizer ignore-call */ 
145
        $date = Calendar_Engine_PearDate::stampCollection($stamp);
Loading history...
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
     * @access protected
155
     */
156
    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...
157
    {
158
        $date = Calendar_Engine_PearDate::stampCollection($stamp);
0 ignored issues
show
Bug Best Practice introduced by
The method Pear\Calendar\Engine\Cal...Date::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

158
        /** @scrutinizer ignore-call */ 
159
        $date = Calendar_Engine_PearDate::stampCollection($stamp);
Loading history...
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
     * @access protected
174
     */
175
    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...
176
    {
177
        $r = array();
178
        Calendar_Engine_PearDate::adjustDate($y, $m, $d, $h, $i, $s);
0 ignored issues
show
Bug Best Practice introduced by
The method Pear\Calendar\Engine\Cal..._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

178
        Calendar_Engine_PearDate::/** @scrutinizer ignore-call */ 
179
                                  adjustDate($y, $m, $d, $h, $i, $s);
Loading history...
179
        $key = $y.$m.$d.$h.$i.$s;
180
        if (!isset($r[$key])) {
181
            $r[$key] = sprintf("%04d-%02d-%02d %02d:%02d:%02d",
182
                                $y, $m, $d, $h, $i, $s);
183
        }
184
        return $r[$key];
185
    }
186
187
    /**
188
     * Set the correct date values (useful for math operations on dates)
189
     *
190
     * @param int &$y year   (2003)
191
     * @param int &$m month  (9)
192
     * @param int &$d day    (13)
193
     * @param int &$h hour   (13)
194
     * @param int &$i minute (34)
195
     * @param int &$s second (53)
196
     *
197
     * @return void
198
     * @access protected
199
     */
200
    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...
201
    {
202
        if ($s < 0) {
203
            $m -= floor($s / 60);
204
            $s = -$s % 60;
205
        }
206
        if ($s > 60) {
207
            $m += floor($s / 60);
208
            $s %= 60;
209
        }
210
        if ($i < 0) {
211
            $h -= floor($i / 60);
212
            $i = -$i % 60;
213
        }
214
        if ($i > 60) {
215
            $h += floor($i / 60);
216
            $i %= 60;
217
        }
218
        if ($h < 0) {
219
            $d -= floor($h / 24);
220
            $h = -$h % 24;
221
        }
222
        if ($h > 24) {
223
            $d += floor($h / 24);
224
            $h %= 24;
225
        }
226
        for(; $m < 1; $y--, $m+=12);
227
        for(; $m > 12; $y++, $m-=12);
228
229
        while ($d < 1) {
230
            if ($m > 1) {
231
                $m--;
232
            } else {
233
                $m = 12;
234
                $y--;
235
            }
236
            $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...
237
        }
238
        for ($max_days = Date_Calc::daysInMonth($m, $y); $d > $max_days; ) {
239
            $d -= $max_days;
240
            if ($m < 12) {
241
                $m++;
242
            } else {
243
                $m = 1;
244
                $y++;
245
            }
246
        }
247
    }
248
249
    /**
250
     * The upper limit on years that the Calendar Engine can work with
251
     *
252
     * @return int 9999
253
     * @access protected
254
     */
255
    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...
256
    {
257
        return 9999;
258
    }
259
260
    /**
261
     * The lower limit on years that the Calendar Engine can work with
262
     *
263
     * @return int 0
264
     * @access protected
265
     */
266
    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...
267
    {
268
        return 0;
269
    }
270
271
    /**
272
     * Returns the number of months in a year
273
     *
274
     * @param int $y year
275
     *
276
     * @return int (12)
277
     * @access protected
278
     */
279
    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

279
    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...
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...
280
    {
281
        return 12;
282
    }
283
284
    /**
285
     * Returns the number of days in a month, given year and month
286
     *
287
     * @param int $y year (2003)
288
     * @param int $m month (9)
289
     *
290
     * @return int days in month
291
     * @access protected
292
     */
293
    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...
294
    {
295
        return (int)Date_Calc::daysInMonth($m, $y);
296
    }
297
298
    /**
299
     * Returns numeric representation of the day of the week in a month,
300
     * given year and month
301
     *
302
     * @param int $y year (2003)
303
     * @param int $m month (9)
304
     *
305
     * @return int from 0 to 7
306
     * @access protected
307
     */
308
    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...
309
    {
310
        return (int)Date_Calc::dayOfWeek(1, $m, $y);
311
    }
312
313
    /**
314
     * Returns the number of days in a week
315
     *
316
     * @param int $y year (2003)
317
     * @param int $m month (9)
318
     * @param int $d day (4)
319
     *
320
     * @return int (7)
321
     * @access protected
322
     */
323
    function getDaysInWeek($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

323
    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

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

323
    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...
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...
324
    {
325
        return 7;
326
    }
327
328
    /**
329
     * Returns the number of the week in the year (ISO-8601), given a date
330
     *
331
     * @param int $y year (2003)
332
     * @param int $m month (9)
333
     * @param int $d day (4)
334
     *
335
     * @return int week number
336
     * @access protected
337
     */
338
    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...
339
    {
340
        //return Date_Calc::weekOfYear($d, $m, $y); //beware, Date_Calc doesn't follow ISO-8601 standard!
341
        list($nYear, $nWeek) = Date_Calc::weekOfYear4th($d, $m, $y);
342
        return $nWeek;
343
    }
344
345
    /**
346
     * Returns the number of the week in the month, given a date
347
     *
348
     * @param int $y        year (2003)
349
     * @param int $m        month (9)
350
     * @param int $d        day (4)
351
     * @param int $firstDay first day of the week (default: monday)
352
     *
353
     * @return int week number
354
     * @access protected
355
     */
356
    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...
357
    {
358
        $weekEnd = ($firstDay == 0) ? $this->getDaysInWeek()-1 : $firstDay-1;
359
        $end_of_week = (int)Date_Calc::nextDayOfWeek($weekEnd, 1, $m, $y, '%e', true);
360
        $w = 1;
361
        while ($d > $end_of_week) {
362
            ++$w;
363
            $end_of_week += $this->getDaysInWeek();
364
        }
365
        return $w;
366
    }
367
368
    /**
369
     * Returns the number of weeks in the month
370
     *
371
     * @param int $y        year (2003)
372
     * @param int $m        month (9)
373
     * @param int $firstDay first day of the week (default: monday)
374
     *
375
     * @return int weeks number
376
     * @access protected
377
     */
378
    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...
379
    {
380
        $FDOM = Date_Calc::firstOfMonthWeekday($m, $y);
381
        if ($FDOM == 0) {
382
            $FDOM = $this->getDaysInWeek();
383
        }
384
        if ($FDOM > $firstDay) {
385
            $daysInTheFirstWeek = $this->getDaysInWeek() - $FDOM + $firstDay;
386
            $weeks = 1;
387
        } else {
388
            $daysInTheFirstWeek = $firstDay - $FDOM;
389
            $weeks = 0;
390
        }
391
        $daysInTheFirstWeek %= $this->getDaysInWeek();
392
        return (int)(ceil(($this->getDaysInMonth($y, $m) - $daysInTheFirstWeek) /
393
                           $this->getDaysInWeek()) + $weeks);
394
    }
395
396
    /**
397
     * Returns the number of the day of the week (0=sunday, 1=monday...)
398
     *
399
     * @param int $y year (2003)
400
     * @param int $m month (9)
401
     * @param int $d day (4)
402
     *
403
     * @return int weekday number
404
     * @access protected
405
     */
406
    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...
407
    {
408
        return Date_Calc::dayOfWeek($d, $m, $y);
409
    }
410
411
    /**
412
     * Returns a list of integer days of the week beginning 0
413
     *
414
     * @param int $y year (2003)
415
     * @param int $m month (9)
416
     * @param int $d day (4)
417
     *
418
     * @return array (0, 1, 2, 3, 4, 5, 6) 1 = Monday
419
     * @access protected
420
     */
421
    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 $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

421
    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

421
    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

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

436
    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...
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 $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

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

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

451
    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

451
    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...
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 $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

451
    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...
452
    {
453
        return 24;
454
    }
455
456
    /**
457
     * Returns the number of minutes in an hour
458
     *
459
     * @param int $y year (2003)
460
     * @param int $m month (9)
461
     * @param int $d day (4)
462
     * @param int $h hour
463
     *
464
     * @return int (60)
465
     * @access protected
466
     */
467
    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

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

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

467
    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

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

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

484
    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

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

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

484
    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...
485
    {
486
        return 60;
487
    }
488
489
    /**
490
     * Checks if the given day is the current day
491
     *
492
     * @param mixed $stamp Any timestamp format recognized by Pear::Date
493
     *
494
     * @return boolean
495
     * @access protected
496
     */
497
    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...
498
    {
499
        static $today = null;
500
        if (is_null($today)) {
501
            $today = new Date();
502
        }
503
        $date = Calendar_Engine_PearDate::stampCollection($stamp);
0 ignored issues
show
Bug Best Practice introduced by
The method Pear\Calendar\Engine\Cal...Date::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

503
        /** @scrutinizer ignore-call */ 
504
        $date = Calendar_Engine_PearDate::stampCollection($stamp);
Loading history...
504
        return (   $date->day == $today->getDay()
505
                && $date->month == $today->getMonth()
506
                && $date->year == $today->getYear()
507
        );
508
    }
509
}
510