Passed
Push — master ( 2af71a...76363e )
by Victor
02:41
created
src/IntervalGraph.php 1 patch
Spacing   +20 added lines, -20 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->boundToNumeric = function (\DateTime $bound) {
49
+        $this->boundToNumeric = function(\DateTime $bound) {
50 50
             return $bound->getTimestamp();
51 51
         };
52 52
 
53
-        $this->boundToString = function (\DateTime $bound) {
53
+        $this->boundToString = function(\DateTime $bound) {
54 54
             return $bound->format("Y-m-d");
55 55
         };
56 56
 
57
-        $this->valueToNumeric = function ($v) {
57
+        $this->valueToNumeric = function($v) {
58 58
             return $v === null ? null : (int)($v * 100);
59 59
         };
60 60
 
61
-        $this->valueToString = function ($v) {
61
+        $this->valueToString = 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
             }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
     public static function truncate(array $intervals, $lowerLimit = null, $upperLimit = null, $padding = false)
161 161
     {
162 162
         if (isset($lowerLimit)) {
163
-            $intervals = array_map(function ($i) use ($lowerLimit) {
163
+            $intervals = array_map(function($i) use ($lowerLimit) {
164 164
                 if ($i[0] < $lowerLimit) { // If the low bound is before the lower bound...
165 165
                     if ($i[1] < $lowerLimit) {
166 166
                         // ... and the high bound is also before the lower bound, set the interval to false.
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 
189 189
         // TODO DRY
190 190
         if (isset($upperLimit)) {
191
-            $intervals = array_map(function ($i) use ($upperLimit) {
191
+            $intervals = array_map(function($i) use ($upperLimit) {
192 192
                 if ($i[1] > $upperLimit) {
193 193
                     if ($i[0] > $upperLimit) {
194 194
                         // If both bounds are after the given upper limit, set the interval to false.
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
         $t = array_column($flatIntervals, 2);
291 291
 
292 292
         // Change bounds to numeric values.
293
-        $numVals = array_map(function (array $i) {
293
+        $numVals = array_map(function(array $i) {
294 294
             return [
295 295
                 ($this->boundToNumeric)($i[0]),
296 296
                 ($this->boundToNumeric)($i[1]),
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
         }, $flatIntervals);
299 299
 
300 300
         // Order by low bound.
301
-        uasort($numVals, function (array $i1, array $i2) {
301
+        uasort($numVals, function(array $i1, array $i2) {
302 302
             return ($i1[0] < $i2[0]) ? -1 : 1;
303 303
         });
304 304
 
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
         $min = reset($numVals)[0];
307 307
 
308 308
         // Substract min from all timestamps.
309
-        $numVals = array_map(function ($i) use ($min) {
309
+        $numVals = array_map(function($i) use ($min) {
310 310
             return [
311 311
                 $i[0] - $min,
312 312
                 $i[1] - $min
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
         }, $numVals);
315 315
 
316 316
         // Order by high bound.
317
-        uasort($numVals, function (array $i1, array $i2) {
317
+        uasort($numVals, function(array $i1, array $i2) {
318 318
             return ($i1[1] < $i2[1]) ? -1 : 1;
319 319
         });
320 320
 
@@ -322,15 +322,15 @@  discard block
 block discarded – undo
322 322
         $max = end($numVals)[1];
323 323
 
324 324
         // Calculate percentages.
325
-        $numVals = array_map(function (array $i) use ($max) {
326
-            return array_map(function ($int) use ($max) {
325
+        $numVals = array_map(function(array $i) use ($max) {
326
+            return array_map(function($int) use ($max) {
327 327
                 return round($int * 100 / $max);
328 328
             }, $i);
329 329
         }, $numVals);
330 330
 
331 331
         // Put values back in, along with the formatted bound.
332 332
         // Since we're using associative sorting functions, we know the keys haven't changed.
333
-        $numVals = array_map(function ($k, array $i) use ($t, $flatIntervals) {
333
+        $numVals = array_map(function($k, array $i) use ($t, $flatIntervals) {
334 334
             if ($flatIntervals[$k][0] === $flatIntervals[$k][1]) {
335 335
                 return [
336 336
                     $i[0], // Single value position percentage
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
                     !empty($t) ? $this->palette->getColor($colorval) : 50, // Interval color
348 348
                     ($this->boundToString)($flatIntervals[$k][0]), // Interval start string value
349 349
                     ($this->boundToString)($flatIntervals[$k][1]), // Interval end string value
350
-                    !empty($t) ? ($stingval) : null,// Interval string value
350
+                    !empty($t) ? ($stingval) : null, // Interval string value
351 351
                 ];
352 352
             }
353 353
         }, array_keys($numVals), $numVals);
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
         // Put discrete values at the end and reset indices.
356 356
         // Reseting indices ensures the processed values are
357 357
         // serialized as correctly ordered JSON arrays.
358
-        usort($numVals, function ($i) {
358
+        usort($numVals, function($i) {
359 359
             return count($i) === 2 ? 1 : -1;
360 360
         });
361 361
 
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
         $adjacentIntervals = $this->calcAdjacentIntervals($signedBounds);
378 378
 
379 379
         // Remove empty interval generated when two or more intervals share a common bound.
380
-        $adjacentIntervals = array_values(array_filter($adjacentIntervals, function ($i) {
380
+        $adjacentIntervals = array_values(array_filter($adjacentIntervals, function($i) {
381 381
             // Use weak comparison in case of object typed bounds.
382 382
             return $i[0] != $i[1];
383 383
         }));
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
      */
403 403
     public static function extractDiscreteValues(array &$intervals)
404 404
     {
405
-        $discreteValues = array_filter($intervals, function ($interval) {
405
+        $discreteValues = array_filter($intervals, function($interval) {
406 406
             return $interval[0] === $interval[1];
407 407
         });
408 408
 
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
             $bounds[] = [$interval[1], isset($interval[2]) ? $interval[2] : null, '-', $key];
430 430
         }
431 431
         // Order the bounds.
432
-        usort($bounds, function (array $d1, array $d2) {
432
+        usort($bounds, function(array $d1, array $d2) {
433 433
             return ($d1[0] < $d2[0]) ? -1 : 1;
434 434
         });
435 435
         return $bounds;
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
     public function calcAdjacentIntervals($bounds)
445 445
     {
446 446
         // Get the values of the original intervals, including nulls.
447
-        $origIntVals = array_map(function ($interval) {
447
+        $origIntVals = array_map(function($interval) {
448 448
             return isset($interval[2]) ? $interval[2] : null;
449 449
         }, $this->intervals);
450 450
 
Please login to merge, or discard this patch.