Passed
Push — master ( 10aac9...b7e2ed )
by Victor
02:16
created
index.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
 $overlapped3 = new IntervalGraph([$base, $date3]);
26 26
 $overlapped = new IntervalGraph([$base, $date1, $date2, $date3]);
27 27
 
28
-$withNull1 = new IntervalGraph([$base, [new DateTime('today'), new DateTime('today + 3 days'), 4 / 10],]);
29
-$withNull2 = new IntervalGraph([$base, [new DateTime('today + 1 day'), new DateTime('today + 2 days')],]);
30
-$withNull3 = new IntervalGraph([$base, [new DateTime('today + 2 day'), new DateTime('today + 3 days'), 4 / 10],]);
31
-$withNull4 = new IntervalGraph([$base, [new DateTime('today + 4 day'), new DateTime('today + 5 days'), 5 / 10],]);
28
+$withNull1 = new IntervalGraph([$base, [new DateTime('today'), new DateTime('today + 3 days'), 4 / 10], ]);
29
+$withNull2 = new IntervalGraph([$base, [new DateTime('today + 1 day'), new DateTime('today + 2 days')], ]);
30
+$withNull3 = new IntervalGraph([$base, [new DateTime('today + 2 day'), new DateTime('today + 3 days'), 4 / 10], ]);
31
+$withNull4 = new IntervalGraph([$base, [new DateTime('today + 4 day'), new DateTime('today + 5 days'), 5 / 10], ]);
32 32
 $withNullIntervals = new IntervalGraph([
33 33
     [$today, new DateTime('today + 3 days'), 4 / 10],
34 34
     [new DateTime('today + 1 day'), new DateTime('today + 2 days')],
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
     [new DateTime('today + 6 day'), new DateTime('today + 9 days'), 2 / 10],
47 47
 ];
48 48
 
49
-$longDateFormat = function (\DateTime $bound){
49
+$longDateFormat = function(\DateTime $bound) {
50 50
     return $bound->format('Y-m-d H:i:s');
51 51
 };
52 52
 
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
  */
58 58
 
59 59
 // An aggregate function for arrays representing fractions with the same denominator.
60
-$agg = function ($a, $b) {
60
+$agg = function($a, $b) {
61 61
     if ($a === null && $b === null) return null;
62 62
     return [$a[0] + $b[0], $b[1]];
63 63
 };
64 64
 
65 65
 // A toNumeric function…
66
-$toNumeric = function ($a) {return $a === null ? null : (int)($a[0] / $a[1] * 100);};
66
+$toNumeric = function($a) {return $a === null ? null : (int)($a[0] / $a[1] * 100); };
67 67
 
68 68
 // A toString function…
69
-$toString = function ($a) {return $a === null ? null : ($a[0] . '/' . $a[1]);};
69
+$toString = function($a) {return $a === null ? null : ($a[0] . '/' . $a[1]); };
70 70
 
71 71
 $fractions = [
72 72
     [$today, new DateTime('today + 3 days'), [2, 10]],
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,9 @@
 block discarded – undo
58 58
 
59 59
 // An aggregate function for arrays representing fractions with the same denominator.
60 60
 $agg = function ($a, $b) {
61
-    if ($a === null && $b === null) return null;
61
+    if ($a === null && $b === null) {
62
+        return null;
63
+    }
62 64
     return [$a[0] + $b[0], $b[1]];
63 65
 };
64 66
 
Please login to merge, or discard this patch.
src/IntervalGraph.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -46,23 +46,23 @@  discard block
 block discarded – undo
46 46
             $this->setIntervals($intervals);
47 47
         }
48 48
 
49
-        $this->boundToStringFunction = function (\DateTime $bound) {
49
+        $this->boundToStringFunction = function(\DateTime $bound) {
50 50
             return $bound->format("Y-m-d");
51 51
         };
52 52
 
53
-        $this->boundToNumericFunction = function (\DateTime $bound) {
53
+        $this->boundToNumericFunction = function(\DateTime $bound) {
54 54
             return $bound->getTimestamp();
55 55
         };
56 56
 
57
-        $this->valueToNumericFunction = function ($v) {
57
+        $this->valueToNumericFunction = function($v) {
58 58
             return $v === null ? null : (int)($v * 100);
59 59
         };
60 60
 
61
-        $this->valueToStringFunction = function ($v) {
61
+        $this->valueToStringFunction = function($v) {
62 62
             return $v === null ? null : ($v * 100 . '%');
63 63
         };
64 64
 
65
-        $this->aggregateFunction = function ($a, $b) {
65
+        $this->aggregateFunction = function($a, $b) {
66 66
             if ($a === null && $b === null) {
67 67
                 return null;
68 68
             }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         self::checkFormat($intervals);
134 134
 
135 135
         if (isset($start)) {
136
-            $intervals = array_map(function ($i) use ($start) {
136
+            $intervals = array_map(function($i) use ($start) {
137 137
                 if ($i[0] < $start) { // If the low bound is before the lower bound...
138 138
                     if ($i[1] < $start) {
139 139
                         // ... and the high bound is also before the lower bound, set the interval to false.
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 
162 162
         // TODO DRY
163 163
         if (isset($end)) {
164
-            $intervals = array_map(function ($i) use ($end) {
164
+            $intervals = array_map(function($i) use ($end) {
165 165
                 if ($i[1] > $end) {
166 166
                     if ($i[0] > $end) {
167 167
                         // If both dates are after the given upper bound, set the interval to false.
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         $t = array_column($intervals, 2);
266 266
 
267 267
         // Change bounds to numeric values.
268
-        $values = array_map(function (array $i) {
268
+        $values = array_map(function(array $i) {
269 269
             return [
270 270
                 ($this->boundToNumericFunction)($i[0]),
271 271
                 ($this->boundToNumericFunction)($i[1]),
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
         }, $intervals);
274 274
 
275 275
         // Order by low bound.
276
-        uasort($values, function (array $i1, array $i2) {
276
+        uasort($values, function(array $i1, array $i2) {
277 277
             return ($i1[0] < $i2[0]) ? -1 : 1;
278 278
         });
279 279
 
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
         $min = reset($values)[0];
282 282
 
283 283
         // Substract min from all timestamps.
284
-        $values = array_map(function ($i) use ($min) {
284
+        $values = array_map(function($i) use ($min) {
285 285
             return [
286 286
                 $i[0] - $min,
287 287
                 $i[1] - $min
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
         }, $values);
290 290
 
291 291
         // Order by high bound.
292
-        uasort($values, function (array $i1, array $i2) {
292
+        uasort($values, function(array $i1, array $i2) {
293 293
             return ($i1[1] < $i2[1]) ? -1 : 1;
294 294
         });
295 295
 
@@ -297,15 +297,15 @@  discard block
 block discarded – undo
297 297
         $max = end($values)[1];
298 298
 
299 299
         // Calculate percentages.
300
-        $values = array_map(function (array $i) use ($max) {
301
-            return array_map(function ($int) use ($max) {
300
+        $values = array_map(function(array $i) use ($max) {
301
+            return array_map(function($int) use ($max) {
302 302
                 return round($int * 100 / $max);
303 303
             }, $i);
304 304
         }, $values);
305 305
 
306 306
         // Put values back in, along with the formatted date.
307 307
         // Since we're using associative sorting functions, we know the keys haven't changed.
308
-        $values = array_map(function ($k, array $i) use ($t, $intervals) {
308
+        $values = array_map(function($k, array $i) use ($t, $intervals) {
309 309
             if ($intervals[$k][0] === $intervals[$k][1]) {
310 310
                 return [
311 311
                     $i[0], // Single value position percentage
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
                     ) : 50, // Interval color
323 323
                     ($this->boundToStringFunction)($intervals[$k][0]), // Interval start string value
324 324
                     ($this->boundToStringFunction)($intervals[$k][1]), // Interval end string value
325
-                    !empty($t) ? (isset($t[$k]) ? ($this->valueToStringFunction)($t[$k]) : null) : null,// Interval string value
325
+                    !empty($t) ? (isset($t[$k]) ? ($this->valueToStringFunction)($t[$k]) : null) : null, // Interval string value
326 326
                 ];
327 327
             }
328 328
         }, array_keys($values), $values);
@@ -330,8 +330,8 @@  discard block
 block discarded – undo
330 330
         // Put isolated dates at the end and reset indices.
331 331
         // Reseting indices ensures the processed values are
332 332
         // serialized as correctly ordered JSON arrays.
333
-        usort($values, function ($i) {
334
-            return count($i) === 2 ?  1 : -1;
333
+        usort($values, function($i) {
334
+            return count($i) === 2 ? 1 : -1;
335 335
         });
336 336
 
337 337
         $this->values = $values;
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
         $flat = $this->calcNewIntervals($dates);
356 356
 
357 357
         // Remove empty interval generated when two or more intervals share a common date.
358
-        $flat = array_values(array_filter($flat, function ($i) {
358
+        $flat = array_values(array_filter($flat, function($i) {
359 359
             return $i[0] !== $i[1];
360 360
         }));
361 361
 
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
      */
380 380
     public static function extractDates(array &$intervals)
381 381
     {
382
-        $dates = array_filter($intervals, function ($interval) {
382
+        $dates = array_filter($intervals, function($interval) {
383 383
             return $interval[0] === $interval[1];
384 384
         });
385 385
 
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
             $dates[] = [$interval[1], isset($interval[2]) ? $interval[2] : null, '-', $key];
405 405
         }
406 406
         // Order the dates.
407
-        usort($dates, function (array $d1, array $d2) {
407
+        usort($dates, function(array $d1, array $d2) {
408 408
             return ($d1[0] < $d2[0]) ? -1 : 1;
409 409
         });
410 410
         return $dates;
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
     public function calcNewIntervals($dates)
420 420
     {
421 421
         // Get the values of the original intervals, including nulls.
422
-        $origIntVals = array_map(function ($interval) {
422
+        $origIntVals = array_map(function($interval) {
423 423
             return isset($interval[2]) ? $interval[2] : null;
424 424
         }, $this->intervals);
425 425
 
Please login to merge, or discard this patch.
src/template.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <div class='intvg'>
2 2
     <?php foreach ($vs as $k => $v) : ?>
3
-        <?php if (count($v) === 2 ): // Isolated date.?>
3
+        <?php if (count($v) === 2): // Isolated date.?>
4 4
             <div class='bar bar-date bar<?= $k; ?>' style='left:<?= $v[0] ?>%;' data-title='<?= $v[1] ?>'></div>
5 5
         <?php else: ?>
6 6
             <div class='bar bar-intv bar<?= $k; ?>'
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,8 +2,11 @@
 block discarded – undo
2 2
     <?php foreach ($vs as $k => $v) : ?>
3 3
         <?php if (count($v) === 2 ): // Isolated date.?>
4 4
             <div class='bar bar-date bar<?= $k; ?>' style='left:<?= $v[0] ?>%;' data-title='<?= $v[1] ?>'></div>
5
-        <?php else: ?>
6
-            <div class='bar bar-intv bar<?= $k; ?>'
5
+        <?php else {
6
+    : ?>
7
+            <div class='bar bar-intv bar<?= $k;
8
+}
9
+?>'
7 10
                  style='left:<?= $v[0] ?>%;right:<?= $v[1] ?>%;background-color:<?= $v[2] ?>'
8 11
                  data-title="<?= $v[3] . ' ➔ ' . $v[4] . (isset($v[5]) ? ' : ' . $v[5] : '') ?>">
9 12
             </div>
Please login to merge, or discard this patch.
src/Palette.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
      */
50 50
     public function setColors(array $palette)
51 51
     {
52
-        usort($palette, function ($p1, $p2) {
52
+        usort($palette, function($p1, $p2) {
53 53
             return $p2[0] - $p1[0];
54 54
         });
55 55
         $this->palette = $palette;
Please login to merge, or discard this patch.