Passed
Push — master ( 3dc74f...81d6e9 )
by Felipe
04:17
created

DateScale   F

Complexity

Total Complexity 70

Size/Duplication

Total Lines 468
Duplicated Lines 0 %

Test Coverage

Coverage 66.27%

Importance

Changes 0
Metric Value
dl 0
loc 468
ccs 165
cts 249
cp 0.6627
rs 2.7272
c 0
b 0
f 0
wmc 70

13 Methods

Rating   Name   Duplication   Size   Complexity  
A AdjustForDST() 0 3 1
A AdjEndDate() 0 3 1
A SetDateAlign() 0 7 2
C AdjTime() 0 68 15
A SetDateFormat() 0 4 1
A SetTimeAlign() 0 7 2
D DoDateAutoScale() 0 143 13
A __construct() 0 10 1
A AdjEndTime() 0 3 1
C AdjDate() 0 59 10
A AdjStartTime() 0 3 1
A AdjStartDate() 0 3 1
F AutoScale() 0 84 21

How to fix   Complexity   

Complex Class

Complex classes like DateScale often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use DateScale, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
/**
4
 * JPGraph v3.6.15
5
 */
6
7
namespace Amenadiel\JpGraph\Graph;
8
9
use Amenadiel\JpGraph\Util;
10
11
/**
12
 * File:        JPGRAPH_DATE.PHP
13
 * // Description: Classes to handle Date scaling
14
 * // Created:     2005-05-02
15
 * // Ver:         $Id: jpgraph_date.php 1106 2009-02-22 20:16:35Z ljp $
16
 * //
17
 * // Copyright (c) Asial Corporation. All rights reserved.
18
 */
19
20
class DateScale extends LinearScale
21
{
22
    private $date_format     = '';
23
    private $iStartAlign     = false;
24
    private $iEndAlign       = false;
25
    private $iStartTimeAlign = false;
26
    private $iEndTimeAlign   = false;
27
28
    /**
29
     * CONSTRUCTOR
30
     */
31 1
    public function __construct($aMin = 0, $aMax = 0, $aType = 'x')
32
    {
33 1
        assert($aType == 'x');
34 1
        assert($aMin <= $aMax);
35
36 1
        $this->type       = $aType;
37 1
        $this->scale      = [$aMin, $aMax];
38 1
        $this->world_size = $aMax - $aMin;
39 1
        $this->ticks      = new LinearTicks();
40 1
        $this->intscale   = true;
41 1
    }
42
43
    /**
44
     * Utility Function AdjDate()
45
     * // Description: Will round a given time stamp to an even year, month or day
46
     * // argument.
47
     */
48 1
    public function AdjDate($aTime, $aRound = 0, $aYearType = false, $aMonthType = false, $aDayType = false)
49
    {
50 1
        $y = (int) date('Y', $aTime);
51 1
        $m = (int) date('m', $aTime);
52 1
        $d = (int) date('d', $aTime);
53 1
        $h = 0;
54 1
        $i = 0;
55 1
        $s = 0;
56 1
        if ($aYearType !== false) {
57 1
            $yearAdj = [0 => 1, 1 => 2, 2 => 5];
58 1
            if ($aRound == 0) {
59 1
                $y = floor($y / $yearAdj[$aYearType]) * $yearAdj[$aYearType];
60
            } else {
61 1
                ++$y;
62 1
                $y = ceil($y / $yearAdj[$aYearType]) * $yearAdj[$aYearType];
63
            }
64 1
            $m = 1;
65 1
            $d = 1;
66
        } elseif ($aMonthType !== false) {
67
            $monthAdj = [0 => 1, 1 => 6];
68
            if ($aRound == 0) {
69
                $m = floor($m / $monthAdj[$aMonthType]) * $monthAdj[$aMonthType];
70
                $d = 1;
71
            } else {
72
                ++$m;
73
                $m = ceil($m / $monthAdj[$aMonthType]) * $monthAdj[$aMonthType];
74
                $d = 1;
75
            }
76
        } elseif ($aDayType !== false) {
77
            if ($aDayType == 0) {
78
                if ($aRound == 1) {
79
                    //++$d;
80
                    $h = 23;
81
                    $i = 59;
82
                    $s = 59;
83
                }
84
            } else {
85
                // Adjust to an even week boundary.
86
                $w = (int) date('w', $aTime); // Day of week 0=Sun, 6=Sat
87
88
                // Adjust to start on Mon
89
                if ($w == 0) {
90
                    $w = 6;
91
                } else {
92
                    --$w;
93
                }
94
95
                if ($aRound == 0) {
96
                    $d -= $w;
97
                } else {
98
                    $d += (7 - $w);
99
                    $h = 23;
100
                    $i = 59;
101
                    $s = 59;
102
                }
103
            }
104
        }
105
106 1
        return mktime($h, $i, $s, $m, $d, $y);
0 ignored issues
show
Bug introduced by
It seems like $y can also be of type double; however, parameter $year of mktime() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

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

106
        return mktime($h, $i, $s, $m, $d, /** @scrutinizer ignore-type */ $y);
Loading history...
Bug introduced by
It seems like $m can also be of type double; however, parameter $month of mktime() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

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

106
        return mktime($h, $i, $s, /** @scrutinizer ignore-type */ $m, $d, $y);
Loading history...
107
    }
108
109
    /**
110
     * Wrapper for AdjDate that will round a timestamp to an even date rounding
111
     * // it downwards.
112
     */
113
114 1
    public function AdjStartDate($aTime, $aYearType = false, $aMonthType = false, $aDayType = false)
115
    {
116 1
        return $this->AdjDate($aTime, 0, $aYearType, $aMonthType, $aDayType);
117
    }
118
119
    /**
120
     * Wrapper for AdjDate that will round a timestamp to an even date rounding
121
     * // it upwards
122
     */
123
124 1
    public function AdjEndDate($aTime, $aYearType = false, $aMonthType = false, $aDayType = false)
125
    {
126 1
        return $this->AdjDate($aTime, 1, $aYearType, $aMonthType, $aDayType);
127
    }
128
129
    /**
130
     * Utility Function AdjTime()
131
     * // Description: Will round a given time stamp to an even time according to
132
     * // argument.
133
     */
134 1
    public function AdjTime($aTime, $aRound = 0, $aHourType = false, $aMinType = false, $aSecType = false)
135
    {
136 1
        $y = (int) date('Y', $aTime);
137 1
        $m = (int) date('m', $aTime);
138 1
        $d = (int) date('d', $aTime);
139 1
        $h = (int) date('H', $aTime);
140 1
        $i = (int) date('i', $aTime);
141 1
        $s = (int) date('s', $aTime);
142 1
        if ($aHourType !== false) {
143 1
            $aHourType %= 6;
144 1
            $hourAdj = [0 => 1, 1 => 2, 2 => 3, 3 => 4, 4 => 6, 5 => 12];
145 1
            if ($aRound == 0) {
146 1
                $h = floor($h / $hourAdj[$aHourType]) * $hourAdj[$aHourType];
147
            } else {
148 1
                if (($h % $hourAdj[$aHourType] == 0) && ($i > 0 || $s > 0)) {
149 1
                    ++$h;
150
                }
151 1
                $h = ceil($h / $hourAdj[$aHourType]) * $hourAdj[$aHourType];
152 1
                if ($h >= 24) {
153
                    $aTime += 86400;
154
                    $y = (int) date('Y', $aTime);
155
                    $m = (int) date('m', $aTime);
156
                    $d = (int) date('d', $aTime);
157
                    $h -= 24;
158
                }
159
            }
160 1
            $i = 0;
161 1
            $s = 0;
162 1
        } elseif ($aMinType !== false) {
163 1
            $aMinType %= 5;
164 1
            $minAdj = [0 => 1, 1 => 5, 2 => 10, 3 => 15, 4 => 30];
165 1
            if ($aRound == 0) {
166 1
                $i = floor($i / $minAdj[$aMinType]) * $minAdj[$aMinType];
167
            } else {
168 1
                if (($i % $minAdj[$aMinType] == 0) && $s > 0) {
169 1
                    ++$i;
170
                }
171 1
                $i = ceil($i / $minAdj[$aMinType]) * $minAdj[$aMinType];
172 1
                if ($i >= 60) {
173
                    $aTime += 3600;
174
                    $y = (int) date('Y', $aTime);
175
                    $m = (int) date('m', $aTime);
176
                    $d = (int) date('d', $aTime);
177
                    $h = (int) date('H', $aTime);
178
                    $i = 0;
179
                }
180
            }
181 1
            $s = 0;
182
        } elseif ($aSecType !== false) {
183
            $aSecType %= 5;
184
            $secAdj = [0 => 1, 1 => 5, 2 => 10, 3 => 15, 4 => 30];
185
            if ($aRound == 0) {
186
                $s = floor($s / $secAdj[$aSecType]) * $secAdj[$aSecType];
187
            } else {
188
                $s = ceil($s / $secAdj[$aSecType] * 1.0) * $secAdj[$aSecType];
189
                if ($s >= 60) {
190
                    $s = 0;
191
                    $aTime += 60;
192
                    $y = (int) date('Y', $aTime);
193
                    $m = (int) date('m', $aTime);
194
                    $d = (int) date('d', $aTime);
195
                    $h = (int) date('H', $aTime);
196
                    $i = (int) date('i', $aTime);
197
                }
198
            }
199
        }
200
201 1
        return mktime($h, $i, $s, $m, $d, $y);
0 ignored issues
show
Bug introduced by
It seems like $h can also be of type double; however, parameter $hour of mktime() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

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

201
        return mktime(/** @scrutinizer ignore-type */ $h, $i, $s, $m, $d, $y);
Loading history...
Bug introduced by
It seems like $i can also be of type double; however, parameter $minute of mktime() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

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

201
        return mktime($h, /** @scrutinizer ignore-type */ $i, $s, $m, $d, $y);
Loading history...
Bug introduced by
It seems like $s can also be of type double; however, parameter $second of mktime() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

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

201
        return mktime($h, $i, /** @scrutinizer ignore-type */ $s, $m, $d, $y);
Loading history...
202
    }
203
204
    /**
205
     * Wrapper for AdjTime that will round a timestamp to an even time rounding
206
     * // it downwards.
207
     * // Example: AdjStartTime(mktime(18,27,13,2,22,2005),false,2) => 18:20
208
     */
209 1
    public function AdjStartTime($aTime, $aHourType = false, $aMinType = false, $aSecType = false)
210
    {
211 1
        return $this->AdjTime($aTime, 0, $aHourType, $aMinType, $aSecType);
212
    }
213
214
    /**
215
     * Wrapper for AdjTime that will round a timestamp to an even time rounding
216
     * // it upwards
217
     * // Example: AdjEndTime(mktime(18,27,13,2,22,2005),false,2) => 18:30
218
     */
219 1
    public function AdjEndTime($aTime, $aHourType = false, $aMinType = false, $aSecType = false)
220
    {
221 1
        return $this->AdjTime($aTime, 1, $aHourType, $aMinType, $aSecType);
222
    }
223
224
    /**
225
     * DateAutoScale
226
     * // Autoscale a date axis given start and end time
227
     * // Returns an array ($start,$end,$major,$minor,$format)
228
     */
229 1
    public function DoDateAutoScale($aStartTime, $aEndTime, $aDensity = 0, $aAdjust = true)
230
    {
231
        // Format of array
232
        // array ( Decision point,  array( array( Major-scale-step-array ),
233
        //       array( Minor-scale-step-array ),
234
        //       array( 0=date-adjust, 1=time-adjust, adjustment-alignment) )
235
        //
236
        $scalePoints =
237
            [
238
            /* Intervall larger than 10 years */
239 1
            SECPERYEAR * 10, [[SECPERYEAR * 5, SECPERYEAR * 2],
240 1
                [SECPERYEAR],
241 1
                [0, YEARADJ_1, 0, YEARADJ_1]],
242
243
            /* Intervall larger than 2 years */
244 1
            SECPERYEAR * 2, [[SECPERYEAR], [SECPERYEAR],
245 1
                [0, YEARADJ_1]],
246
247
            /* Intervall larger than 90 days (approx 3 month) */
248 1
            SECPERDAY * 90, [[SECPERDAY * 30, SECPERDAY * 14, SECPERDAY * 7, SECPERDAY],
249 1
                [SECPERDAY * 5, SECPERDAY * 7, SECPERDAY, SECPERDAY],
250 1
                [0, MONTHADJ_1, 0, DAYADJ_WEEK, 0, DAYADJ_1, 0, DAYADJ_1]],
251
252
            /* Intervall larger than 30 days (approx 1 month) */
253 1
            SECPERDAY * 30, [[SECPERDAY * 14, SECPERDAY * 7, SECPERDAY * 2, SECPERDAY],
254 1
                [SECPERDAY, SECPERDAY, SECPERDAY, SECPERDAY],
255 1
                [0, DAYADJ_WEEK, 0, DAYADJ_1, 0, DAYADJ_1, 0, DAYADJ_1]],
256
257
            /* Intervall larger than 7 days */
258 1
            SECPERDAY * 7, [[SECPERDAY, SECPERHOUR * 12, SECPERHOUR * 6, SECPERHOUR * 2],
259 1
                [SECPERHOUR * 6, SECPERHOUR * 3, SECPERHOUR, SECPERHOUR],
260 1
                [0, DAYADJ_1, 1, HOURADJ_12, 1, HOURADJ_6, 1, HOURADJ_1]],
261
262
            /* Intervall larger than 1 day */
263 1
            SECPERDAY, [[SECPERDAY, SECPERHOUR * 12, SECPERHOUR * 6, SECPERHOUR * 2, SECPERHOUR],
264 1
                [SECPERHOUR * 6, SECPERHOUR * 2, SECPERHOUR, SECPERHOUR, SECPERHOUR],
265 1
                [1, HOURADJ_12, 1, HOURADJ_6, 1, HOURADJ_1, 1, HOURADJ_1]],
266
267
            /* Intervall larger than 12 hours */
268 1
            SECPERHOUR * 12, [[SECPERHOUR * 2, SECPERHOUR, SECPERMIN * 30, 900, 600],
269
                [1800, 1800, 900, 300, 300],
270 1
                [1, HOURADJ_1, 1, MINADJ_30, 1, MINADJ_15, 1, MINADJ_10, 1, MINADJ_5]],
271
272
            /* Intervall larger than 2 hours */
273 1
            SECPERHOUR * 2, [[SECPERHOUR, SECPERMIN * 30, 900, 600, 300],
274
                [1800, 900, 300, 120, 60],
275 1
                [1, HOURADJ_1, 1, MINADJ_30, 1, MINADJ_15, 1, MINADJ_10, 1, MINADJ_5]],
276
277
            /* Intervall larger than 1 hours */
278 1
            SECPERHOUR, [[SECPERMIN * 30, 900, 600, 300], [900, 300, 120, 60],
279 1
                [1, MINADJ_30, 1, MINADJ_15, 1, MINADJ_10, 1, MINADJ_5]],
280
281
            /* Intervall larger than 30 min */
282 1
            SECPERMIN * 30, [[SECPERMIN * 15, SECPERMIN * 10, SECPERMIN * 5, SECPERMIN],
283
                [300, 300, 60, 10],
284 1
                [1, MINADJ_15, 1, MINADJ_10, 1, MINADJ_5, 1, MINADJ_1]],
285
286
            /* Intervall larger than 1 min */
287 1
            SECPERMIN, [[SECPERMIN, 15, 10, 5],
288
                [15, 5, 2, 1],
289 1
                [1, MINADJ_1, 1, SECADJ_15, 1, SECADJ_10, 1, SECADJ_5]],
290
291
            /* Intervall larger than 10 sec */
292 1
            10, [[5, 2],
293
                [1, 1],
294 1
                [1, SECADJ_5, 1, SECADJ_1]],
295
296
            /* Intervall larger than 1 sec */
297 1
            1, [[1],
298
                [1],
299 1
                [1, SECADJ_1]],
300
        ];
301
302 1
        $ns = count($scalePoints);
0 ignored issues
show
Unused Code introduced by
The assignment to $ns is dead and can be removed.
Loading history...
303
        // Establish major and minor scale units for the date scale
304 1
        $diff = $aEndTime - $aStartTime;
305 1
        if ($diff < 1) {
306
            return false;
307
        }
308
309 1
        $done = false;
310 1
        $i    = 0;
311 1
        while (!$done) {
312 1
            if ($diff > $scalePoints[2 * $i]) {
313
                // Get major and minor scale for this intervall
314 1
                $scaleSteps = $scalePoints[2 * $i + 1];
315 1
                $major      = $scaleSteps[0][min($aDensity, count($scaleSteps[0]) - 1)];
316
                // Try to find out which minor step looks best
317 1
                $minor = $scaleSteps[1][min($aDensity, count($scaleSteps[1]) - 1)];
318 1
                if ($aAdjust) {
319
                    // Find out how we should align the start and end timestamps
320 1
                    $idx = 2 * min($aDensity, floor(count($scaleSteps[2]) / 2) - 1);
321 1
                    if ($scaleSteps[2][$idx] === 0) {
322
                        // Use date adjustment
323 1
                        $adj = $scaleSteps[2][$idx + 1];
324 1
                        if ($adj >= 30) {
325 1
                            $start = $this->AdjStartDate($aStartTime, $adj - 30);
326 1
                            $end   = $this->AdjEndDate($aEndTime, $adj - 30);
327
                        } elseif ($adj >= 20) {
328
                            $start = $this->AdjStartDate($aStartTime, false, $adj - 20);
329
                            $end   = $this->AdjEndDate($aEndTime, false, $adj - 20);
330
                        } else {
331
                            $start = $this->AdjStartDate($aStartTime, false, false, $adj);
332
                            $end   = $this->AdjEndDate($aEndTime, false, false, $adj);
333
                            // We add 1 second for date adjustment to make sure we end on 00:00 the following day
334
                            // This makes the final major tick be srawn when we step day-by-day instead of ending
335
                            // on xx:59:59 which would not draw the final major tick
336 1
                            ++$end;
337
                        }
338
                    } else {
339
                        // Use time adjustment
340 1
                        $adj = $scaleSteps[2][$idx + 1];
341 1
                        if ($adj >= 30) {
342 1
                            $start = $this->AdjStartTime($aStartTime, $adj - 30);
343 1
                            $end   = $this->AdjEndTime($aEndTime, $adj - 30);
344 1
                        } elseif ($adj >= 20) {
345 1
                            $start = $this->AdjStartTime($aStartTime, false, $adj - 20);
346 1
                            $end   = $this->AdjEndTime($aEndTime, false, $adj - 20);
347
                        } else {
348
                            $start = $this->AdjStartTime($aStartTime, false, false, $adj);
349
                            $end   = $this->AdjEndTime($aEndTime, false, false, $adj);
350
                        }
351
                    }
352
                }
353
                // If the overall date span is larger than 1 day ten we show date
354 1
                $format = '';
355 1
                if (($end - $start) > SECPERDAY) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $start does not seem to be defined for all execution paths leading up to this point.
Loading history...
Comprehensibility Best Practice introduced by
The variable $end does not seem to be defined for all execution paths leading up to this point.
Loading history...
356 1
                    $format = 'Y-m-d ';
357
                }
358
                // If the major step is less than 1 day we need to whow hours + min
359 1
                if ($major < SECPERDAY) {
360 1
                    $format .= 'H:i';
361
                }
362
                // If the major step is less than 1 min we need to show sec
363 1
                if ($major < 60) {
364
                    $format .= ':s';
365
                }
366 1
                $done = true;
367
            }
368 1
            ++$i;
369
        }
370
371 1
        return [$start, $end, $major, $minor, $format];
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $format does not seem to be defined for all execution paths leading up to this point.
Loading history...
Comprehensibility Best Practice introduced by
The variable $minor does not seem to be defined for all execution paths leading up to this point.
Loading history...
Comprehensibility Best Practice introduced by
The variable $major does not seem to be defined for all execution paths leading up to this point.
Loading history...
372
    }
373
374
    // Overrides the automatic determined date format. Must be a valid date() format string
375 1
    public function SetDateFormat($aFormat)
376
    {
377 1
        $this->date_format = $aFormat;
378 1
        $this->ticks->SetLabelDateFormat($this->date_format);
379 1
    }
380
381
    public function AdjustForDST($aFlg = true)
382
    {
383
        $this->ticks->AdjustForDST($aFlg);
384
    }
385
386
    public function SetDateAlign($aStartAlign, $aEndAlign = false)
387
    {
388
        if ($aEndAlign === false) {
389
            $aEndAlign = $aStartAlign;
390
        }
391
        $this->iStartAlign = $aStartAlign;
392
        $this->iEndAlign   = $aEndAlign;
393
    }
394
395 1
    public function SetTimeAlign($aStartAlign, $aEndAlign = false)
396
    {
397 1
        if ($aEndAlign === false) {
398 1
            $aEndAlign = $aStartAlign;
399
        }
400 1
        $this->iStartTimeAlign = $aStartAlign;
401 1
        $this->iEndTimeAlign   = $aEndAlign;
402 1
    }
403
404 1
    public function AutoScale($img, $aStartTime, $aEndTime, $aNumSteps, $_adummy = false)
405
    {
406
        // We need to have one dummy argument to make the signature of AutoScale()
407
        // identical to LinearScale::AutoScale
408 1
        if ($aStartTime == $aEndTime) {
409
            // Special case when we only have one data point.
410
            // Create a small artifical intervall to do the autoscaling
411
            $aStartTime -= 10;
412
            $aEndTime += 10;
413
        }
414 1
        $done = false;
415 1
        $i    = 0;
416 1
        while (!$done && $i < 5) {
417 1
            list($adjstart, $adjend, $maj, $min, $format) = $this->DoDateAutoScale($aStartTime, $aEndTime, $i);
418 1
            $n                                            = floor(($adjend - $adjstart) / $maj);
419 1
            if ($n * 1.7 > $aNumSteps) {
420 1
                $done = true;
421
            }
422 1
            ++$i;
423
        }
424
425
        /*
426
        if( 0 ) { // DEBUG
427
        echo "    Start =".date("Y-m-d H:i:s",$aStartTime)."<br>";
428
        echo "    End   =".date("Y-m-d H:i:s",$aEndTime)."<br>";
429
        echo "Adj Start =".date("Y-m-d H:i:s",$adjstart)."<br>";
430
        echo "Adj End   =".date("Y-m-d H:i:s",$adjend)."<p>";
431
        echo "Major = $maj s, ".floor($maj/60)."min, ".floor($maj/3600)."h, ".floor($maj/86400)."day<br>";
432
        echo "Min = $min s, ".floor($min/60)."min, ".floor($min/3600)."h, ".floor($min/86400)."day<br>";
433
        echo "Format=$format<p>";
434
        }
435
         */
436
437 1
        if ($this->iStartTimeAlign !== false && $this->iStartAlign !== false) {
438
            Util\JpGraphError::RaiseL(3001);
439
            //('It is only possible to use either SetDateAlign() or SetTimeAlign() but not both');
440
        }
441
442 1
        if ($this->iStartTimeAlign !== false) {
443 1
            if ($this->iStartTimeAlign >= 30) {
444
                $adjstart = $this->AdjStartTime($aStartTime, $this->iStartTimeAlign - 30);
445 1
            } elseif ($this->iStartTimeAlign >= 20) {
446 1
                $adjstart = $this->AdjStartTime($aStartTime, false, $this->iStartTimeAlign - 20);
447
            } else {
448
                $adjstart = $this->AdjStartTime($aStartTime, false, false, $this->iStartTimeAlign);
449
            }
450
        }
451 1
        if ($this->iEndTimeAlign !== false) {
452 1
            if ($this->iEndTimeAlign >= 30) {
453
                $adjend = $this->AdjEndTime($aEndTime, $this->iEndTimeAlign - 30);
454 1
            } elseif ($this->iEndTimeAlign >= 20) {
455 1
                $adjend = $this->AdjEndTime($aEndTime, false, $this->iEndTimeAlign - 20);
456
            } else {
457
                $adjend = $this->AdjEndTime($aEndTime, false, false, $this->iEndTimeAlign);
458
            }
459
        }
460
461 1
        if ($this->iStartAlign !== false) {
462
            if ($this->iStartAlign >= 30) {
463
                $adjstart = $this->AdjStartDate($aStartTime, $this->iStartAlign - 30);
464
            } elseif ($this->iStartAlign >= 20) {
465
                $adjstart = $this->AdjStartDate($aStartTime, false, $this->iStartAlign - 20);
466
            } else {
467
                $adjstart = $this->AdjStartDate($aStartTime, false, false, $this->iStartAlign);
468
            }
469
        }
470 1
        if ($this->iEndAlign !== false) {
471
            if ($this->iEndAlign >= 30) {
472
                $adjend = $this->AdjEndDate($aEndTime, $this->iEndAlign - 30);
473
            } elseif ($this->iEndAlign >= 20) {
474
                $adjend = $this->AdjEndDate($aEndTime, false, $this->iEndAlign - 20);
475
            } else {
476
                $adjend = $this->AdjEndDate($aEndTime, false, false, $this->iEndAlign);
477
            }
478
        }
479 1
        $this->Update($img, $adjstart, $adjend);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $adjstart does not seem to be defined for all execution paths leading up to this point.
Loading history...
Comprehensibility Best Practice introduced by
The variable $adjend does not seem to be defined for all execution paths leading up to this point.
Loading history...
480 1
        if (!$this->ticks->IsSpecified()) {
481 1
            $this->ticks->Set($maj, $min);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $min does not seem to be defined for all execution paths leading up to this point.
Loading history...
Comprehensibility Best Practice introduced by
The variable $maj does not seem to be defined for all execution paths leading up to this point.
Loading history...
482
        }
483
484 1
        if ($this->date_format == '') {
485 1
            $this->ticks->SetLabelDateFormat($format);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $format does not seem to be defined for all execution paths leading up to this point.
Loading history...
486
        } else {
487 1
            $this->ticks->SetLabelDateFormat($this->date_format);
488
        }
489 1
    }
490
}
491