shims.php ➔ cal_info()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * If ext/calendar is not installed, then provide the necessary shims.
4
 *
5
 * @author    Greg Roach <[email protected]>
6
 * @copyright (c) 2014-2020 Greg Roach
7
 * @license   This program is free software: you can redistribute it and/or modify
8
 *            it under the terms of the GNU General Public License as published by
9
 *            the Free Software Foundation, either version 3 of the License, or
10
 *            (at your option) any later version.
11
 *
12
 *            This program is distributed in the hope that it will be useful,
13
 *            but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *            GNU General Public License for more details.
16
 *
17
 *            You should have received a copy of the GNU General Public License
18
 *            along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
use Fisharebest\ExtCalendar\Shim;
22
23
if (!defined('CAL_GREGORIAN')) {
24
    Shim::create();
25
26
    define('CAL_GREGORIAN', 0);
27
    define('CAL_JULIAN', 1);
28
    define('CAL_JEWISH', 2);
29
    define('CAL_FRENCH', 3);
30
    define('CAL_NUM_CALS', 4);
31
    define('CAL_DOW_DAYNO', 0);
32
    define('CAL_DOW_SHORT', Shim::shouldEmulateBug67960() ? 1 : 2);
33
    define('CAL_DOW_LONG', Shim::shouldEmulateBug67960() ? 2 : 1);
34
    define('CAL_MONTH_GREGORIAN_SHORT', 0);
35
    define('CAL_MONTH_GREGORIAN_LONG', 1);
36
    define('CAL_MONTH_JULIAN_SHORT', 2);
37
    define('CAL_MONTH_JULIAN_LONG', 3);
38
    define('CAL_MONTH_JEWISH', 4);
39
    define('CAL_MONTH_FRENCH', 5);
40
    define('CAL_EASTER_DEFAULT', 0);
41
    define('CAL_EASTER_ROMAN', 1);
42
    define('CAL_EASTER_ALWAYS_GREGORIAN', 2);
43
    define('CAL_EASTER_ALWAYS_JULIAN', 3);
44
    define('CAL_JEWISH_ADD_ALAFIM_GERESH', 2);
45
    define('CAL_JEWISH_ADD_ALAFIM', 4);
46
    define('CAL_JEWISH_ADD_GERESHAYIM', 8);
47
48
    /**
49
     * @param int $calendar_id
50
     * @param int $month
51
     * @param int $year
52
     *
53
     * @return int|bool
54
     */
55
56
    function cal_days_in_month($calendar_id, $month, $year)
0 ignored issues
show
Coding Style introduced by
function cal_days_in_month() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
57
    {
58
        return Shim::calDaysInMonth($calendar_id, $month, $year);
59
    }
60
61
    /**
62
     * @param int $julian_day
63
     * @param int $calendar_id
64
     *
65
     * @return array|bool
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use array|boolean.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
66
     */
67
    function cal_from_jd($julian_day, $calendar_id)
0 ignored issues
show
Coding Style introduced by
function cal_from_jd() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
68
    {
69
        return Shim::calFromJd($julian_day, $calendar_id);
70
    }
71
72
    /**
73
     * @param int $calendar_id
74
     *
75
     * @return array|bool
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use array<string,string[]|in...olean>|boolean>|boolean.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
76
     */
77
    function cal_info($calendar_id = -1)
0 ignored issues
show
Coding Style introduced by
function cal_info() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
78
    {
79
        return Shim::calInfo($calendar_id);
80
    }
81
82
    /**
83
     * @param int $calendar_id
84
     * @param int $month
85
     * @param int $day
86
     * @param int $year
87
     *
88
     * @return int|bool
89
     */
90
    function cal_to_jd($calendar_id, $month, $day, $year)
0 ignored issues
show
Coding Style introduced by
function cal_to_jd() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
91
    {
92
        return Shim::calToJd($calendar_id, $month, $day, $year);
93
    }
94
95
    /**
96
     * @param int|null $year
97
     *
98
     * @return int|bool
0 ignored issues
show
Documentation introduced by
Should the return type not be boolean|integer|double?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
99
     */
100
    function easter_date($year = null)
0 ignored issues
show
Coding Style introduced by
function easter_date() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
101
    {
102
        return Shim::easterDate($year ? $year : (int)date('Y'));
103
    }
104
105
    /**
106
     * @param int|null $year
107
     * @param int      $method
108
     *
109
     * @return int
110
     */
111
    function easter_days($year = null, $method = CAL_EASTER_DEFAULT)
0 ignored issues
show
Coding Style introduced by
function easter_days() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
112
    {
113
        return Shim::easterDays($year ? $year : (int)date('Y'), $method);
114
    }
115
116
    /**
117
     * @param int $month
118
     * @param int $day
119
     * @param int $year
120
     *
121
     * @return int
122
     */
123
    function FrenchToJD($month, $day, $year)
0 ignored issues
show
Coding Style introduced by
function FrenchToJD() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
124
    {
125
        return Shim::frenchToJd($month, $day, $year);
126
    }
127
128
    /**
129
     * @param int $month
130
     * @param int $day
131
     * @param int $year
132
     *
133
     * @return int
134
     */
135
    function GregorianToJD($month, $day, $year)
0 ignored issues
show
Coding Style introduced by
function GregorianToJD() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
136
    {
137
        return Shim::gregorianToJd($month, $day, $year);
138
    }
139
140
    /**
141
     * @param int $julian_day
142
     * @param int $mode
143
     *
144
     * @return int|string
145
     */
146
    function JDDayOfWeek($julian_day, $mode = CAL_DOW_DAYNO)
0 ignored issues
show
Coding Style introduced by
function JDDayOfWeek() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
147
    {
148
        return Shim::jdDayOfWeek($julian_day, $mode);
149
    }
150
151
    /**
152
     * @param int $julian_day
153
     * @param int $mode
154
     *
155
     * @return string
156
     */
157
    function JDMonthName($julian_day, $mode)
0 ignored issues
show
Coding Style introduced by
function JDMonthName() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
158
    {
159
        return Shim::jdMonthName($julian_day, $mode);
160
    }
161
162
    /**
163
     * @param int $julian_day
164
     *
165
     * @return string
166
     */
167
    function JDToFrench($julian_day)
0 ignored issues
show
Coding Style introduced by
function JDToFrench() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
168
    {
169
        return Shim::jdToFrench($julian_day);
170
    }
171
172
    /**
173
     * @param int $julian_day
174
     *
175
     * @return string
176
     */
177
    function JDToGregorian($julian_day)
0 ignored issues
show
Coding Style introduced by
function JDToGregorian() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
178
    {
179
        return Shim::jdToGregorian($julian_day);
180
    }
181
182
    /**
183
     * @param int $julian_day
184
     * @param bool $hebrew
185
     * @param int $flags
186
     *
187
     * @return string|bool
188
     */
189
    function jdtojewish($julian_day, $hebrew = false, $flags = 0)
190
    {
191
        return Shim::jdToJewish($julian_day, $hebrew, $flags);
192
    }
193
194
    /**
195
     * @param int $julian_day
196
     *
197
     * @return string
198
     */
199
    function JDToJulian($julian_day)
0 ignored issues
show
Coding Style introduced by
function JDToJulian() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
200
    {
201
        return Shim::jdToJulian($julian_day);
202
    }
203
204
    /**
205
     * @param int $julian_day
206
     *
207
     * @return int|false
208
     */
209
    function jdtounix($julian_day)
210
    {
211
        return Shim::jdToUnix($julian_day);
212
    }
213
214
    /**
215
     * @param int $month
216
     * @param int $day
217
     * @param int $year
218
     *
219
     * @return int
220
     */
221
    function JewishToJD($month, $day, $year)
0 ignored issues
show
Coding Style introduced by
function JewishToJD() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
222
    {
223
        return Shim::jewishToJd($month, $day, $year);
224
    }
225
226
    /**
227
     * @param int $month
228
     * @param int $day
229
     * @param int $year
230
     *
231
     * @return int
232
     */
233
    function JulianToJD($month, $day, $year)
0 ignored issues
show
Coding Style introduced by
function JulianToJD() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
234
    {
235
        return Shim::julianToJd($month, $day, $year);
236
    }
237
238
    /**
239
     * @param int|null $timestamp
240
     *
241
     * @return false|int
242
     */
243
    function unixtojd($timestamp = null)
244
    {
245
        return Shim::unixToJd($timestamp ? $timestamp : time());
246
    }
247
}
248