@@ -95,7 +95,7 @@ |
||
95 | 95 | public function orderGroups() : array { |
96 | 96 | $groups = $this->getGroups(); |
97 | 97 | usort($groups, static function($a, $b) { |
98 | - return $a->getOrder() - $b->getOrder(); |
|
98 | + return $a->getOrder()-$b->getOrder(); |
|
99 | 99 | }); |
100 | 100 | return $groups; |
101 | 101 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @return bool |
24 | 24 | */ |
25 | 25 | public static function isPowerOf2(int $x) : bool { |
26 | - return ($x !== 0) && ($x & ($x - 1)) === 0; |
|
26 | + return ($x !== 0) && ($x&($x-1)) === 0; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public static function previousPowerOf2(int $x) : int { |
49 | 49 | // Left bit shift by the bit length of the previous number |
50 | - return 1 << (strlen(decbin($x)) - 1); |
|
50 | + return 1 << (strlen(decbin($x))-1); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -64,8 +64,7 @@ discard block |
||
64 | 64 | // Get initial data |
65 | 65 | if ($this->topLevelOnly) { |
66 | 66 | $data = $this->container->getTopLevel(); |
67 | - } |
|
68 | - else { |
|
67 | + } else { |
|
69 | 68 | $data = $this->container->get(); |
70 | 69 | } |
71 | 70 | |
@@ -105,8 +104,7 @@ discard block |
||
105 | 104 | } |
106 | 105 | $ids[] = $obj->getId(); |
107 | 106 | } |
108 | - } |
|
109 | - else { |
|
107 | + } else { |
|
110 | 108 | $data = array_unique($data); |
111 | 109 | } |
112 | 110 | } |
@@ -131,11 +129,9 @@ discard block |
||
131 | 129 | protected function sortData(array &$data) : void { |
132 | 130 | if (isset($this->sorter)) { |
133 | 131 | $data = $this->sorter->sort($data); |
134 | - } |
|
135 | - elseif (isset($this->sortClosure)) { |
|
132 | + } elseif (isset($this->sortClosure)) { |
|
136 | 133 | uasort($data, $this->sortClosure); |
137 | - } |
|
138 | - elseif (isset($this->sortProperty)) { |
|
134 | + } elseif (isset($this->sortProperty)) { |
|
139 | 135 | uasort($data, [$this, 'sortByPropertyCallback']); |
140 | 136 | } |
141 | 137 | } |
@@ -274,14 +270,12 @@ discard block |
||
274 | 270 | $property2 = null; |
275 | 271 | if (is_object($value1) && isset($value1->$property)) { |
276 | 272 | $property1 = $value1->$property; |
277 | - } |
|
278 | - elseif (is_array($value1) && isset($value1[$property])) { |
|
273 | + } elseif (is_array($value1) && isset($value1[$property])) { |
|
279 | 274 | $property1 = $value1[$property]; |
280 | 275 | } |
281 | 276 | if (is_object($value2) && isset($value2->$property)) { |
282 | 277 | $property2 = $value2->$property; |
283 | - } |
|
284 | - elseif (is_array($value2) && isset($value2[$property])) { |
|
278 | + } elseif (is_array($value2) && isset($value2[$property])) { |
|
285 | 279 | $property2 = $value2[$property]; |
286 | 280 | } |
287 | 281 |
@@ -112,8 +112,7 @@ discard block |
||
112 | 112 | $data['categories'] = [ |
113 | 113 | $this->object->getId() => $this->getCategoryData($this->object), |
114 | 114 | ]; |
115 | - } |
|
116 | - elseif ($this->object instanceof WithCategories) { |
|
115 | + } elseif ($this->object instanceof WithCategories) { |
|
117 | 116 | $data['categories'] = []; |
118 | 117 | foreach ($this->object->getCategories() as $category) { |
119 | 118 | $data['categories'][$category->getId()] = $this->getCategoryData($category); |
@@ -153,8 +152,7 @@ discard block |
||
153 | 152 | $data['rounds'] = [ |
154 | 153 | $this->object->getId() => $this->getRoundData($this->object), |
155 | 154 | ]; |
156 | - } |
|
157 | - elseif ($this->object instanceof WithRounds) { |
|
155 | + } elseif ($this->object instanceof WithRounds) { |
|
158 | 156 | $data['rounds'] = []; |
159 | 157 | foreach ($this->object->getRounds() as $round) { |
160 | 158 | $data['rounds'][$round->getId()] = $this->getRoundData($round); |
@@ -197,8 +195,7 @@ discard block |
||
197 | 195 | foreach ($this->object->getProgressions() as $progression) { |
198 | 196 | $data['progressions'][] = $this->getProgressionData($progression); |
199 | 197 | } |
200 | - } |
|
201 | - elseif ($this->object instanceof WithGroups) { |
|
198 | + } elseif ($this->object instanceof WithGroups) { |
|
202 | 199 | foreach ($this->object->getGroups() as $group) { |
203 | 200 | $data['groups'][$group->getId()] = $this->getGroupData($group); |
204 | 201 | foreach ($group->getProgressions() as $progression) { |
@@ -564,7 +564,7 @@ |
||
564 | 564 | * @return bool |
565 | 565 | */ |
566 | 566 | public static function isObject($data) : bool { |
567 | - return is_object($data) || (is_array($data) && !empty($data) && array_keys($data) !== range(0, count($data) - 1)); |
|
567 | + return is_object($data) || (is_array($data) && !empty($data) && array_keys($data) !== range(0, count($data)-1)); |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | /** |
@@ -490,8 +490,7 @@ |
||
490 | 490 | foreach (((array) $data) as $key => $value) { |
491 | 491 | self::validateParams($value, array_merge($keys, [$key]), $setting['parameters'][$key]); |
492 | 492 | } |
493 | - } |
|
494 | - else { |
|
493 | + } else { |
|
495 | 494 | foreach (((array) $data) as $object) { |
496 | 495 | foreach (((array) $object) as $key => $value) { |
497 | 496 | self::validateParams($value, array_merge($keys, [$key]), $setting['parameters'][$key]); |
@@ -42,7 +42,7 @@ |
||
42 | 42 | * |
43 | 43 | */ |
44 | 44 | public function getJson() : string { |
45 | - return json_encode($this->get(), JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES); |
|
45 | + return json_encode($this->get(), JSON_THROW_ON_ERROR|JSON_UNESCAPED_SLASHES); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -118,8 +118,7 @@ |
||
118 | 118 | // Check tournament type (can be a preset) |
119 | 119 | if (empty($setting['type']) || $setting['type'] === 'general') { |
120 | 120 | $tournament = new Tournament(); |
121 | - } |
|
122 | - else { |
|
121 | + } else { |
|
123 | 122 | $tournament = new $setting['type']; |
124 | 123 | } |
125 | 124 | self::$root = $tournament; // If set - Tournament is always root |