Passed
Push — master ( dfc48c...761598 )
by Victor
02:28
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/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.
src/IntervalGraph.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -48,23 +48,23 @@  discard block
 block discarded – undo
48 48
             $this->setIntervals($intervals);
49 49
         }
50 50
 
51
-        $this->boundToNumeric = function (\DateTime $bound) {
51
+        $this->boundToNumeric = function(\DateTime $bound) {
52 52
             return $bound->getTimestamp();
53 53
         };
54 54
 
55
-        $this->boundToString = function (\DateTime $bound) {
55
+        $this->boundToString = function(\DateTime $bound) {
56 56
             return $bound->format("Y-m-d");
57 57
         };
58 58
 
59
-        $this->valueToNumeric = function ($v) {
59
+        $this->valueToNumeric = function($v) {
60 60
             return $v === null ? null : (int)($v * 100);
61 61
         };
62 62
 
63
-        $this->valueToString = function ($v) {
63
+        $this->valueToString = function($v) {
64 64
             return $v === null ? null : ($v * 100 . '%');
65 65
         };
66 66
 
67
-        $this->aggregateFunction = function ($a, $b) {
67
+        $this->aggregateFunction = function($a, $b) {
68 68
             if ($a === null && $b === null) {
69 69
                 return null;
70 70
             }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
         $t = array_column($flatIntervals, 2);
198 198
 
199 199
         // Change bounds to numeric values.
200
-        $numVals = array_map(function (array $i) {
200
+        $numVals = array_map(function(array $i) {
201 201
             return [
202 202
                 ($this->boundToNumeric)($i[0]),
203 203
                 ($this->boundToNumeric)($i[1]),
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
         }, $flatIntervals);
206 206
 
207 207
         // Order by low bound.
208
-        uasort($numVals, function (array $i1, array $i2) {
208
+        uasort($numVals, function(array $i1, array $i2) {
209 209
             return ($i1[0] < $i2[0]) ? -1 : 1;
210 210
         });
211 211
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
         $min = reset($numVals)[0];
214 214
 
215 215
         // Substract min from all timestamps.
216
-        $numVals = array_map(function ($i) use ($min) {
216
+        $numVals = array_map(function($i) use ($min) {
217 217
             return [
218 218
                 $i[0] - $min,
219 219
                 $i[1] - $min
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
         }, $numVals);
222 222
 
223 223
         // Order by high bound.
224
-        uasort($numVals, function (array $i1, array $i2) {
224
+        uasort($numVals, function(array $i1, array $i2) {
225 225
             return ($i1[1] < $i2[1]) ? -1 : 1;
226 226
         });
227 227
 
@@ -229,15 +229,15 @@  discard block
 block discarded – undo
229 229
         $max = end($numVals)[1];
230 230
 
231 231
         // Calculate percentages.
232
-        $numVals = array_map(function (array $i) use ($max) {
233
-            return array_map(function ($int) use ($max) {
232
+        $numVals = array_map(function(array $i) use ($max) {
233
+            return array_map(function($int) use ($max) {
234 234
                 return round($int * 100 / $max);
235 235
             }, $i);
236 236
         }, $numVals);
237 237
 
238 238
         // Put values back in, along with the formatted bound.
239 239
         // Since we're using associative sorting functions, we know the keys haven't changed.
240
-        $numVals = array_map(function ($k, array $i) use ($t, $flatIntervals) {
240
+        $numVals = array_map(function($k, array $i) use ($t, $flatIntervals) {
241 241
             if ($flatIntervals[$k][0] === $flatIntervals[$k][1]) {
242 242
                 return [
243 243
                     $i[0], // Single value position percentage
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
                     !empty($t) ? $this->palette->getColor($colorval) : 50, // Interval color
255 255
                     ($this->boundToString)($flatIntervals[$k][0]), // Interval start string value
256 256
                     ($this->boundToString)($flatIntervals[$k][1]), // Interval end string value
257
-                    !empty($t) ? ($stingval) : null,// Interval string value
257
+                    !empty($t) ? ($stingval) : null, // Interval string value
258 258
                 ];
259 259
             }
260 260
         }, array_keys($numVals), $numVals);
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
         // Put discrete values at the end and reset indices.
263 263
         // Reseting indices ensures the processed values are
264 264
         // serialized as correctly ordered JSON arrays.
265
-        usort($numVals, function ($i) {
265
+        usort($numVals, function($i) {
266 266
             return count($i) === 2 ? 1 : -1;
267 267
         });
268 268
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
         $adjacentIntervals = $this->calcAdjacentIntervals($signedBounds);
285 285
 
286 286
         // Remove empty interval generated when two or more intervals share a common bound.
287
-        $adjacentIntervals = array_values(array_filter($adjacentIntervals, function ($i) {
287
+        $adjacentIntervals = array_values(array_filter($adjacentIntervals, function($i) {
288 288
             // Use weak comparison in case of object typed bounds.
289 289
             return $i[0] != $i[1];
290 290
         }));
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
      */
310 310
     public static function extractDiscreteValues(array &$intervals)
311 311
     {
312
-        $discreteValues = array_filter($intervals, function ($interval) {
312
+        $discreteValues = array_filter($intervals, function($interval) {
313 313
             return $interval[0] === $interval[1];
314 314
         });
315 315
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
             $bounds[] = [$interval[1], isset($interval[2]) ? $interval[2] : null, '-', $key];
337 337
         }
338 338
         // Order the bounds.
339
-        usort($bounds, function (array $d1, array $d2) {
339
+        usort($bounds, function(array $d1, array $d2) {
340 340
             return ($d1[0] < $d2[0]) ? -1 : 1;
341 341
         });
342 342
         return $bounds;
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
     public function calcAdjacentIntervals($bounds)
352 352
     {
353 353
         // Get the values of the original intervals, including nulls.
354
-        $origIntVals = array_map(function ($interval) {
354
+        $origIntVals = array_map(function($interval) {
355 355
             return isset($interval[2]) ? $interval[2] : null;
356 356
         }, $this->intervals);
357 357
 
Please login to merge, or discard this patch.