Completed
Branch master (55a138)
by Michael
03:21
created

functions0.php ➔ ext_DateAdd2()   C

Complexity

Conditions 11
Paths 11

Size

Total Lines 43
Code Lines 37

Duplication

Lines 43
Ratio 100 %

Importance

Changes 0
Metric Value
cc 11
eloc 37
nc 11
nop 3
dl 43
loc 43
rs 5.2653
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
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 28 and the first side effect is on line 21.

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
 * classGenerator
4
 * walls_watermarks.
5
 *
6
 * You may not change or alter any portion of this comment or credits
7
 * of supporting developers from this source code or any supporting source code
8
 * which is considered copyrighted (c) material of the original comment or credit authors.
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
 *
13
 *
14
 *
15
 * L'utilisation de ce formulaire d'adminitration suppose
16
 * que la classe correspondante de la table a été générées avec classGenerator
17
 **/
18
19
use XoopsModules\Extcal;
20
21
require_once XOOPS_ROOT_PATH . '/class/uploader.php';
22
23
/**
24
 * @param $eventId
25
 *
26
 * @return array
27
 */
28 View Code Duplication
function extcal_getEvent($eventId)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
{
30
    $eventHandler = Extcal\Helper::getInstance()->getHandler(_EXTCAL_CLN_EVENT);
31
    $event        = $eventHandler->getEvent($eventId);
32
    $t            = $event->getVars();
33
    $data         = [];
34
    //    while (list($key, $val) = each($t)) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% 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...
35
    foreach ($t as $key => $val) {
36
        $data[$key] = $val['value'];
37
    }
38
39
    return $data;
40
}
41
42
/**
43
 * @param $REQUEST
44
 * @param $event_picture1
45
 * @param $event_picture2
46
 */
47 View Code Duplication
function extcal_loadImg(&$REQUEST, &$event_picture1, &$event_picture2)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
{
49
    ///////////////////////////////////////////////////////////////////////////////
50
    $uploaddir_event = XOOPS_ROOT_PATH . '/uploads/extcal/';
51
    $uploadurl_event = XOOPS_URL . '/uploads/extcal/';
0 ignored issues
show
Unused Code introduced by
$uploadurl_event is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
52
    //$picture = '';
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% 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...
53
    for ($j = 1; $j < 3; ++$j) {
54
        $delimg = @$REQUEST['delimg_' . $j . ''];
55
        $delimg = isset($delimg) ? (int)$delimg : 0;
56
        if (0 == $delimg && !empty($REQUEST['xoops_upload_file'][$j])) {
57
            $upload = new \XoopsMediaUploader($uploaddir_event, [
58
                'image/gif',
59
                'image/jpeg',
60
                'image/pjpeg',
61
                'image/x-png',
62
                'image/png',
63
                'image/jpg',
64
            ], 3145728, null, null);
65
            if ($upload->fetchMedia($REQUEST['xoops_upload_file'][$j])) {
66
                $upload->setPrefix('event_');
67
                $upload->fetchMedia($REQUEST['xoops_upload_file'][$j]);
68
                if (!$upload->upload()) {
69
                    $errors = $upload->getErrors();
70
                    redirect_header('javascript:history.go(-1)', 3, $errors);
71
                } else {
72
                    if (1 == $j) {
73
                        $event_picture1 = $upload->getSavedFileName();
74
                    } elseif (2 == $j) {
75
                        $event_picture2 = $upload->getSavedFileName();
76
                    }
77
                }
78
            } elseif (!empty($REQUEST['file' . $j])) {
79
                if (1 == $j) {
80
                    $event_picture1 = $REQUEST['file' . $j];
81
                } elseif (2 == $j) {
82
                    $event_picture2 = $REQUEST['file' . $j];
83
                }
84
            }
85
        } else {
86
            $url_event = XOOPS_ROOT_PATH . '/uploads/extcal/' . $REQUEST['file' . $j];
87
            if (1 == $j) {
88
                $event_picture1 = '';
89
            } elseif (2 == $j) {
90
                $event_picture2 = '';
91
            }
92
            if (is_file($url_event)) {
93
                chmod($url_event, 0777);
94
                unlink($url_event);
95
            }
96
        }
97
    }
98
    //exit;
99
    ///////////////////////////////////////////////////////////////////////////////
100
}
101
102
/*******************************************************************
103
 *
104
 ******************************************************************
105
 * @param        $cat
106
 * @param bool   $addNone
107
 * @param string $name
108
 * @return XoopsFormSelect
109
 */
110 View Code Duplication
function getListCategories($cat, $addNone = true, $name = 'cat')
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
111
{
112
    global $xoopsUser;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
113
    // Category selectbox
114
     $catHandler   = Extcal\Helper::getInstance()->getHandler(_EXTCAL_CLN_CAT);
115
116
    $catsList  = $catHandler->getAllCat($xoopsUser);
117
    $catSelect = new \XoopsFormSelect('', $name, $cat);
118
    if ($addNone) {
119
        $catSelect->addOption(0, ' ');
120
    }
121
122
    foreach ($catsList as $catList) {
123
        $catSelect->addOption($catList->getVar('cat_id'), $catList->getVar('cat_name'));
124
    }
125
126
    return $catSelect;
127
}
128
129
/*******************************************************************
130
 *
131
 ******************************************************************
132
 * @param string $name
133
 * @param        $cat
134
 * @return array
135
 */
136 View Code Duplication
function getCheckeCategories($name = 'cat', $cat)
0 ignored issues
show
Unused Code introduced by
The parameter $name is not used and could be removed.

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

Loading history...
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
137
{
138
    global $xoopsUser;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
139
    // Category selectbox
140
    //<option style="background-color:#00FFFF;">VARCHAR</option>
141
142
     $catHandler   = Extcal\Helper::getInstance()->getHandler(_EXTCAL_CLN_CAT);
143
    $catsList   = $catHandler->getAllCat($xoopsUser);
144
145
    $t = [];
146
    foreach ($catsList as $catList) {
147
        $cat_id    = $catList->getVar('cat_id');
148
        $name      = $catList->getVar('cat_name');
149
        $cat_color = $catList->getVar('cat_color');
150
        $checked   = in_array($cat_id, $cat) ? 'checked' : '';
151
        $cat       = ''
152
                     . "<div style='float:left; margin-left:5px;'>"
153
                     . "<input type='checkbox' name='{$name}[{$cat_id}]' value='1' {$checked}>"
154
                     . "<div style='absolute:left;height:12px; width:6px; background-color:#{$cat_color}; border:1px solid black; float:left; margin-right:5px;' ></div>"
155
                     . " {$name}"
156
                     . '</div>';
157
158
        $t[] = $cat;
159
    }
160
161
    return $t;
162
}
163
164
/*******************************************************************
165
 *
166
 ******************************************************************
167
 * @param string $name
168
 * @param string $caption
169
 * @param        $defaut
170
 * @param bool   $addNone
171
 * @return XoopsFormSelect
172
 */
173 View Code Duplication
function getListOrderBy($name = 'orderby', $caption = '', $defaut, $addNone = false)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
174
{
175
    global $xoopsUser;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
176
177
    $select = new \XoopsFormSelect($caption, $name, $defaut);
178
    if ($addNone) {
179
        $select->addOption('', '');
180
    }
181
182
    $select->addOption('year ASC', _MD_EXTCAL_YEAR . ' ' . _MD_EXTCAL_ORDER_BY_ASC);
183
    $select->addOption('year DESC', _MD_EXTCAL_YEAR . ' ' . _MD_EXTCAL_ORDER_BY_DESC);
184
185
    $select->addOption('month ASC', _MD_EXTCAL_MONTH . ' ' . _MD_EXTCAL_ORDER_BY_ASC);
186
    $select->addOption('month DESC', _MD_EXTCAL_MONTH . ' ' . _MD_EXTCAL_ORDER_BY_DESC);
187
188
    $select->addOption('event_title ASC', _MD_EXTCAL_ALPHA . ' ' . _MD_EXTCAL_ORDER_BY_ASC);
189
    $select->addOption('event_title DESC', _MD_EXTCAL_ALPHA . ' ' . _MD_EXTCAL_ORDER_BY_DESC);
190
191
    $select->addOption('cat_name ASC', _MD_EXTCAL_CATEGORY . ' ' . _MD_EXTCAL_ORDER_BY_ASC);
192
    $select->addOption('cat_name DESC', _MD_EXTCAL_CATEGORY . ' ' . _MD_EXTCAL_ORDER_BY_DESC);
193
194
    return $select;
195
}
196
197
/*******************************************************************
198
 *
199
 ******************************************************************
200
 * @param string $name
201
 * @param string $caption
202
 * @param        $defaut
203
 * @return XoopsFormSelect
204
 */
205 View Code Duplication
function getListAndOr($name = 'andor', $caption = '', $defaut)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
206
{
207
    global $xoopsUser;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
208
209
    $select = new \XoopsFormSelect($caption, $name, $defaut);
210
211
    $select->addOption('AND', _MD_EXTCAL_AND);
212
    $select->addOption('OR', _MD_EXTCAL_OR);
213
214
    return $select;
215
}
216
217
/*******************************************************************
218
 *
219
 ******************************************************************
220
 * @param        $name
221
 * @param        $caption
222
 * @param        $defaut
223
 * @param        $options
224
 * @param string $sep
225
 * @return XoopsFormSelect
226
 */
227 View Code Duplication
function getList($name, $caption, $defaut, $options, $sep = ';')
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
228
{
229
    global $xoopsUser;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
230
231
    $select = new \XoopsFormSelect($caption, $name, $defaut);
232
    if (!is_array($options)) {
233
        $options = explode($sep, $options);
234
    }
235
236
    for ($h = 0, $count = count($options); $h < $count; ++$h) {
237
        $select->addOption($h, $options[$h]);
238
    }
239
240
    return $select;
241
}
242
243
/*******************************************************************
244
 *
245
 ******************************************************************
246
 * @param        $ts
247
 * @param        $startMonth
248
 * @param        $endMonth
249
 * @param string $mode
250
 * @return DateTime
251
 */
252
function getDateBetweenDates($ts, $startMonth, $endMonth, $mode = 'w')
0 ignored issues
show
Unused Code introduced by
The parameter $mode is not used and could be removed.

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

Loading history...
253
{
254
    $d = new DateTime($periodStart);
0 ignored issues
show
Bug introduced by
The variable $periodStart does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
255
    $d->setTimestamp($ts);
256
257
    //echo "<br>affichage des periodes : <br>";
258
    $begin = new DateTime();
259
    $begin->setTimestamp($startMonth);
260
    //echo $begin->format("d/m/Y à H\hi:s").'<br>'; // 03/10/2007 à 19h39:53
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
261
262
    $end = new DateTime();
263
    $end->setTimestamp($endMonth);
264
    //echo $end->format("d/m/Y à H\hi:s").'<br>'; // 03/10/2007 à 19h39:53
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
265
    //echo "<hr>";
266
    $interval = DateInterval::createFromDateString('next sunday');
267
    $period   = new DatePeriod($begin, $interval, $end);
0 ignored issues
show
Unused Code introduced by
$period is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
268
    //echoDateArray($period);
269
270
    //echo "<hr>{$interval}";
271
    return $d;
272
273
    //echo mktime($heure, $minute, $seconde, $mois, $jour, $an);
0 ignored issues
show
Unused Code Comprehensibility introduced by
69% 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...
274
275
    //
276
    //   $jour = date('d', $ts);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% 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...
277
    //   $mois = date('m', $ts);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% 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...
278
    //   $an = date('Y', $ts);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% 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...
279
    //   $heure = date('H', $ts);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% 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...
280
    //   $minute = date('i', $ts);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% 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...
281
    //   $seconde = date('s', $ts);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% 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...
282
    //   $d->setDate($heure,$minute,$seconde,$mois,$jour,$an);
0 ignored issues
show
Unused Code Comprehensibility introduced by
89% 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...
283
284
    // <?php
285
    // $interval = DateInterval::createFromDateString('next sunday');
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% 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...
286
    // $period = new DatePeriod($begin, $interval, $end);
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% 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...
287
    // foreach ($period as $dt) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% 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...
288
    //   echo $dt->format( "l Y-m-d H:i:s\n" );
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% 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...
289
}
290
291
/*
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% 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...
292
Sunday 2009-11-01 00:00:00
293
Sunday 2009-11-08 00:00:00
294
Sunday 2009-11-15 00:00:00
295
Sunday 2009-11-22 00:00:00
296
Sunday 2009-11-29 00:00:00
297
Sunday 2009-12-06 00:00:00
298
...
299
*/
300
/**
301
 * @param $period
302
 */
303
function echoDateArray($period)
304
{
305
    foreach ($period as $dt) {
306
        echo $dt->format("l Y-m-d H:i:s\n") . '<br>';
307
    }
308
}
309
310
/*****************************************************************/
311
/**
312
 * @param        $t
313
 * @param string $msg
314
 */
315 View Code Duplication
function ext_echoArray($t, $msg = '')
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
316
{
317
    if ('' != $msg) {
318
        echo "<hr>{$msg}<hr>";
319
    }
320
321
    $txt = print_r($t, true);
322
    echo '<pre>Number of items: ' . count($t) . "<br>{$txt}</pre>";
323
}
324
325
/*****************************************************************/
326
/**
327
 * @param        $line
328
 * @param string $msg
329
 */
330
function ext_echo($line, $msg = '')
331
{
332
    if ('' != $msg) {
333
        echo "<hr>{$msg}<hr>";
334
    }
335
    echo $line . '<br>';
336
}
337
338
/*****************************************************************/
339
/**
340
 * @param        $tsName
341
 * @param string $msg
342
 */
343
function ext_echoTSN($tsName, $msg = '')
344
{
345
    global $$tsName;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
346
    $ts = $$tsName;
347
    ext_echoTSU($ts, $tsName, $msg = '');
348
}
349
350
/*****************************************************************/
351
/**
352
 * @param        $ts
353
 * @param        $tsName
354
 * @param string $msg
355
 */
356 View Code Duplication
function ext_echoTSU($ts, $tsName, $msg = '')
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
357
{
358
    if ('' != $msg) {
359
        echo "<hr>{$msg}<hr>";
360
    }
361
362
    echo 'date --->' . $tsName . ' = ' . $ts . ' - ' . date('d-m-Y H:m:s', $ts) . '<br>';
363
}
364
365
/*****************************************************************/
366
/*****************************************************************/
367
/**
368
 * @param        $date
369
 * @param string $sep
370
 *
371
 * @return int
0 ignored issues
show
Documentation introduced by
Should the return type not be integer|null?

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...
372
 */
373 View Code Duplication
function ext_convert_date($date, $sep = '-')
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
374
{
375
    $lstSep = '/ .';
376
377
    for ($h = 0, $count = strlen($lstSep); $h < $count; ++$h) {
0 ignored issues
show
Unused Code introduced by
++$h; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
378
        $sep2replace = substr($lstSep, $h, 1);
379
        if (strpos($date, $sep2replace)) {
380
            $date = str_replace($sep2replace, $sep, $date);
381
        }
382
383
        return strtotime($date);
384
    }
385
}
386
387
/**
388
 * @param     $givendate
389
 * @param int $day
390
 * @param int $mth
391
 * @param int $yr
392
 *
393
 * @return int
394
 */
395 View Code Duplication
function ext_DateAdd($givendate, $day = 0, $mth = 0, $yr = 0)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
396
{
397
    //$cd = strtotime($givendate);
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% 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...
398
    $cd      = $givendate;
399
    $newdate = date('Y-m-d h:i:s', mktime(date('h', $cd), date('i', $cd), date('s', $cd), date('m', $cd) + $mth, date('d', $cd) + $day, date('Y', $cd) + $yr));
400
401
    return strtotime($newdate);
402
}
403
404
/**
405
 * @param $date
406
 * @param $number
407
 * @param $interval
408
 *
409
 * @return int
410
 */
411 View Code Duplication
function ext_DateAdd2($date, $number, $interval = 'd')
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
412
{
413
    $date_time_array = getdate($date);
414
    $hours           = $date_time_array['hours'];
415
    $minutes         = $date_time_array['minutes'];
416
    $seconds         = $date_time_array['seconds'];
417
    $month           = $date_time_array['mon'];
418
    $day             = $date_time_array['mday'];
419
    $year            = $date_time_array['year'];
420
421
    switch ($interval) {
422
423
        case 'yyyy':
424
            $year += $number;
425
            break;
426
        case 'q':
427
            $year += ($number * 3);
428
            break;
429
        case 'm':
430
            $month += $number;
431
            break;
432
        case 'y':
433
        case 'd':
434
        case 'w':
435
            $day += $number;
436
            break;
437
        case 'ww':
438
            $day += ($number * 7);
439
            break;
440
        case 'h':
441
            $hours += $number;
442
            break;
443
        case 'n':
444
            $minutes += $number;
445
            break;
446
        case 's':
447
            $seconds += $number;
448
            break;
449
    }
450
    $timestamp = mktime($hours, $minutes, $seconds, $month, $day, $year);
451
452
    return $timestamp;
453
}
454
455
// function date_diff($date1, $date2) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% 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...
456
//     $current = $date1;
457
//     $datetime2 = date_create($date2);
458
//     $count = 0;
459
//     while (date_create($current) < $datetime2) {
460
//         $current = gmdate("Y-m-d", strtotime("+1 day", strtotime($current)));
461
//         ++$count;
462
//     }
463
//     return $count;
464
// }
465
466
/**************************************************************************/
467
/**
468
 * @param $color
469
 * @param $plancher
470
 * @param $plafond
471
 *
472
 * @return string
473
 */
474
function eclaircirCouleur($color, $plancher, $plafond)
475
{
476
//    require_once __DIR__ . '/../class/ColorTools.php';
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% 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...
477
478
    //$ct = new ColorTools();
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% 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...
479
    //return $ct->eclaircir($color,$plancher,$plafond);
0 ignored issues
show
Unused Code Comprehensibility introduced by
85% 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...
480
    return ColorTools::eclaircir($color, $plancher, $plafond);
481
}
482
/**************************************************************************/
483