@@ -9,19 +9,19 @@ discard block |
||
9 | 9 | |
10 | 10 | $today = new DateTime('today'); |
11 | 11 | |
12 | -$base = D::intv(0,5); |
|
13 | -$intv1 = D::intv(0,4, 7/10); |
|
14 | -$intv2 = D::intv(1,5,3/10); |
|
15 | -$intv3 = D::intv(2,3,3/10); |
|
12 | +$base = D::intv(0, 5); |
|
13 | +$intv1 = D::intv(0, 4, 7 / 10); |
|
14 | +$intv2 = D::intv(1, 5, 3 / 10); |
|
15 | +$intv3 = D::intv(2, 3, 3 / 10); |
|
16 | 16 | $overlapped1 = D::intvg([$base, $intv1]); |
17 | 17 | $overlapped2 = D::intvg([$base, $intv2]); |
18 | 18 | $overlapped3 = D::intvg([$base, $intv3]); |
19 | 19 | $overlapped = D::intvg([$base, $intv1, $intv2, $intv3]); |
20 | 20 | |
21 | -$withNull1 = D::intvg([$base, D::intv(0,3,4/10)]); |
|
22 | -$withNull2 = D::intvg([$base, D::intv(1,2)]); |
|
23 | -$withNull3 = D::intvg([$base, D::intv(2,3,4/10)]); |
|
24 | -$withNull4 = D::intvg([$base, D::intv(4,5,5/10)]); |
|
21 | +$withNull1 = D::intvg([$base, D::intv(0, 3, 4 / 10)]); |
|
22 | +$withNull2 = D::intvg([$base, D::intv(1, 2)]); |
|
23 | +$withNull3 = D::intvg([$base, D::intv(2, 3, 4 / 10)]); |
|
24 | +$withNull4 = D::intvg([$base, D::intv(4, 5, 5 / 10)]); |
|
25 | 25 | $withNullIntervals = D::intvg([ |
26 | 26 | [$today, new DateTime('today + 3 days'), 4 / 10], |
27 | 27 | [new DateTime('today + 1 day'), new DateTime('today + 2 days')], |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | D::intv(6, 9, 2 / 10), |
40 | 40 | ]; |
41 | 41 | |
42 | -$longDateFormat = function (DateTime $bound) { |
|
42 | +$longDateFormat = function(DateTime $bound) { |
|
43 | 43 | return $bound->format('Y-m-d H:i:s'); |
44 | 44 | }; |
45 | 45 | |
@@ -50,18 +50,18 @@ discard block |
||
50 | 50 | */ |
51 | 51 | |
52 | 52 | // An aggregate function for arrays representing fractions with the same denominator. |
53 | -$agg = function ($a, $b) { |
|
53 | +$agg = function($a, $b) { |
|
54 | 54 | if ($a === null && $b === null) return null; |
55 | 55 | return [$a[0] + $b[0], $b[1]]; |
56 | 56 | }; |
57 | 57 | |
58 | 58 | // A toNumeric function… |
59 | -$toNumeric = function ($a) { |
|
59 | +$toNumeric = function($a) { |
|
60 | 60 | return $a === null ? null : (int)($a[0] / $a[1] * 100); |
61 | 61 | }; |
62 | 62 | |
63 | 63 | // A toString function… |
64 | -$toString = function ($a) { |
|
64 | +$toString = function($a) { |
|
65 | 65 | return $a === null ? null : ($a[0] . '/' . $a[1]); |
66 | 66 | }; |
67 | 67 | |
@@ -97,13 +97,13 @@ discard block |
||
97 | 97 | |
98 | 98 | $withDates = (D::intvg([ |
99 | 99 | [$intv1, $intv1], |
100 | - D::intv(0,4,7/10), |
|
100 | + D::intv(0, 4, 7 / 10), |
|
101 | 101 | [$intv2, $intv2], |
102 | 102 | D::intv(1, 5, 3 / 10), |
103 | 103 | D::intv(2, 3, 3 / 10), |
104 | 104 | [$intv3, $intv3], |
105 | 105 | ])) |
106 | - ->setBoundToString($longDateFormat);; |
|
106 | + ->setBoundToString($longDateFormat); ; |
|
107 | 107 | |
108 | 108 | $intvGraphs = []; |
109 | 109 | foreach (range(0, 20) as $t) { |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | { |
28 | 28 | try { |
29 | 29 | $start = new DateTime("today + $start days"); |
30 | - $end = (new DateTime("today + $end days"))->setTime(23,59,59); |
|
30 | + $end = (new DateTime("today + $end days"))->setTime(23, 59, 59); |
|
31 | 31 | } catch (Exception $e) {} |
32 | 32 | |
33 | 33 | return [$start, $end, $value]; |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | * @return IntervalGraph |
41 | 41 | */ |
42 | 42 | public static function intvg($args) { |
43 | - $substractStep = function (DateTime $bound) { |
|
43 | + $substractStep = function(DateTime $bound) { |
|
44 | 44 | return (clone $bound)->sub(new DateInterval('PT1S')); |
45 | 45 | }; |
46 | 46 | |
47 | - $addStep = function (DateTime $bound) { |
|
47 | + $addStep = function(DateTime $bound) { |
|
48 | 48 | return (clone $bound)->add(new DateInterval('PT1S')); |
49 | 49 | }; |
50 | 50 | return (new IntervalGraph($args)) |
@@ -60,23 +60,23 @@ discard block |
||
60 | 60 | $this->setIntervals($intervals); |
61 | 61 | } |
62 | 62 | |
63 | - $this->boundToNumeric = function (DateTime $bound) { |
|
63 | + $this->boundToNumeric = function(DateTime $bound) { |
|
64 | 64 | return $bound->getTimestamp(); |
65 | 65 | }; |
66 | 66 | |
67 | - $this->boundToString = function (DateTime $bound) { |
|
67 | + $this->boundToString = function(DateTime $bound) { |
|
68 | 68 | return $bound->format("Y-m-d"); |
69 | 69 | }; |
70 | 70 | |
71 | - $this->valueToNumeric = function ($v) { |
|
71 | + $this->valueToNumeric = function($v) { |
|
72 | 72 | return $v === null ? null : (int)($v * 100); |
73 | 73 | }; |
74 | 74 | |
75 | - $this->valueToString = function ($v) { |
|
75 | + $this->valueToString = function($v) { |
|
76 | 76 | return $v === null ? null : ($v * 100 . '%'); |
77 | 77 | }; |
78 | 78 | |
79 | - $this->aggregateFunction = function ($a, $b) { |
|
79 | + $this->aggregateFunction = function($a, $b) { |
|
80 | 80 | if ($a === null && $b === null) { |
81 | 81 | return null; |
82 | 82 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | // Order by low bound. |
259 | - uasort($numVals, function (array $i1, array $i2) { |
|
259 | + uasort($numVals, function(array $i1, array $i2) { |
|
260 | 260 | return ($i1[0] < $i2[0]) ? -1 : 1; |
261 | 261 | }); |
262 | 262 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | } |
273 | 273 | |
274 | 274 | // Order by high bound. |
275 | - uasort($numVals, function (array $i1, array $i2) { |
|
275 | + uasort($numVals, function(array $i1, array $i2) { |
|
276 | 276 | return ($i1[1] < $i2[1]) ? -1 : 1; |
277 | 277 | }); |
278 | 278 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | !empty($originalValues) ? $this->palette->getColor($colval) : 50, // Interval color |
316 | 316 | ($this->boundToString)($lowBound), // Interval start string value |
317 | 317 | ($this->boundToString)($highBound), // Interval end string value |
318 | - !empty($originalValues) ? ($strval) : null,// Interval string value |
|
318 | + !empty($originalValues) ? ($strval) : null, // Interval string value |
|
319 | 319 | ]; |
320 | 320 | } |
321 | 321 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | // Put discrete values at the end and reset indices. |
324 | 324 | // Reseting indices ensures the processed values are |
325 | 325 | // serialized as correctly ordered JSON arrays. |
326 | - usort($numVals, function ($i) { |
|
326 | + usort($numVals, function($i) { |
|
327 | 327 | return count($i) === 2 ? 1 : -1; |
328 | 328 | }); |
329 | 329 | |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | $adjacentIntervals = $this->calcAdjacentIntervals($signedBounds); |
346 | 346 | |
347 | 347 | // Remove empty interval generated when two or more intervals share a common bound. |
348 | - $adjacentIntervals = array_values(array_filter($adjacentIntervals, function ($i) { |
|
348 | + $adjacentIntervals = array_values(array_filter($adjacentIntervals, function($i) { |
|
349 | 349 | // Use weak comparison in case of object typed bounds. |
350 | 350 | return $i[0] != $i[1]; |
351 | 351 | })); |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | */ |
371 | 371 | public static function extractDiscreteValues(array &$intervals) |
372 | 372 | { |
373 | - $discreteValues = array_filter($intervals, function ($interval) { |
|
373 | + $discreteValues = array_filter($intervals, function($interval) { |
|
374 | 374 | return $interval[0] === $interval[1]; |
375 | 375 | }); |
376 | 376 | |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | $bounds[] = [$interval[0], '+', true, $key, isset($interval[2]) ? $interval[2] : null]; |
408 | 408 | } |
409 | 409 | // Order the bounds. |
410 | - usort($bounds, function (array $d1, array $d2) { |
|
410 | + usort($bounds, function(array $d1, array $d2) { |
|
411 | 411 | return ($d1[0] < $d2[0]) ? -1 : 1; |
412 | 412 | }); |
413 | 413 | return $bounds; |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | } |
512 | 512 | |
513 | 513 | // Order by high bound. |
514 | - uasort($numericIntervals, function (array $i1, array $i2) { |
|
514 | + uasort($numericIntervals, function(array $i1, array $i2) { |
|
515 | 515 | return ($i1[1] < $i2[1]) ? -1 : 1; |
516 | 516 | }); |
517 | 517 | |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | // Put discrete values at the end and reset indices. |
541 | 541 | // Reseting indices ensures the processed values are |
542 | 542 | // serialized as correctly ordered JSON arrays. |
543 | - usort($numericIntervals, function ($i) { |
|
543 | + usort($numericIntervals, function($i) { |
|
544 | 544 | return !is_array($i) ? 1 : -1; |
545 | 545 | }); |
546 | 546 |