@@ -66,7 +66,7 @@ |
||
| 66 | 66 | shuffle($teams); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - $split = ceil(count($teams) / count($wheres)); |
|
| 69 | + $split = ceil(count($teams)/count($wheres)); |
|
| 70 | 70 | foreach ($wheres as $where) { |
| 71 | 71 | if (count($teams) > 0) { |
| 72 | 72 | $where->addTeam(...array_splice($teams, 0, $split)); |
@@ -61,8 +61,7 @@ discard block |
||
| 61 | 61 | $teams = $this->getTeams(true, Constants::SEED); |
| 62 | 62 | if ($this::isSeeded($teams)) { |
| 63 | 63 | Functions::sortAlternate($teams); |
| 64 | - } |
|
| 65 | - else { |
|
| 64 | + } else { |
|
| 66 | 65 | shuffle($teams); |
| 67 | 66 | } |
| 68 | 67 | |
@@ -94,8 +93,7 @@ discard block |
||
| 94 | 93 | } |
| 95 | 94 | if ($ordered) { |
| 96 | 95 | $returnTeams = $this->sortTeams($ordering); |
| 97 | - } |
|
| 98 | - else { |
|
| 96 | + } else { |
|
| 99 | 97 | $returnTeams = $this->teams->unique()->get(); |
| 100 | 98 | } |
| 101 | 99 | |
@@ -145,8 +143,7 @@ discard block |
||
| 145 | 143 | if ($this instanceof WithGroupsInterface) { |
| 146 | 144 | $filter = new Filter($filters, $this->getGroups()); |
| 147 | 145 | $filter->filter($teams); |
| 148 | - } |
|
| 149 | - else if ($this instanceof Group) { |
|
| 146 | + } else if ($this instanceof Group) { |
|
| 150 | 147 | $filter = new Filter($filters, [$this]); |
| 151 | 148 | $filter->filter($teams); |
| 152 | 149 | } |
@@ -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 | } |
@@ -132,11 +130,9 @@ discard block |
||
| 132 | 130 | protected function sortData(array &$data) : void { |
| 133 | 131 | if (isset($this->sorter)) { |
| 134 | 132 | $data = $this->sorter->sort($data); |
| 135 | - } |
|
| 136 | - elseif (isset($this->sortClosure)) { |
|
| 133 | + } elseif (isset($this->sortClosure)) { |
|
| 137 | 134 | uasort($data, $this->sortClosure); |
| 138 | - } |
|
| 139 | - elseif (isset($this->sortProperty)) { |
|
| 135 | + } elseif (isset($this->sortProperty)) { |
|
| 140 | 136 | uasort($data, [$this, 'sortByPropertyCallback']); |
| 141 | 137 | } |
| 142 | 138 | } |
@@ -226,8 +222,7 @@ discard block |
||
| 226 | 222 | } |
| 227 | 223 | return $a < $b ? -1 : 1; |
| 228 | 224 | }; |
| 229 | - } |
|
| 230 | - else { |
|
| 225 | + } else { |
|
| 231 | 226 | $this->sortClosure = $callback; |
| 232 | 227 | } |
| 233 | 228 | return $this; |
@@ -309,14 +304,12 @@ discard block |
||
| 309 | 304 | $property2 = null; |
| 310 | 305 | if (is_object($value1) && isset($value1->$property)) { |
| 311 | 306 | $property1 = $value1->$property; |
| 312 | - } |
|
| 313 | - elseif (is_array($value1) && isset($value1[$property])) { |
|
| 307 | + } elseif (is_array($value1) && isset($value1[$property])) { |
|
| 314 | 308 | $property1 = $value1[$property]; |
| 315 | 309 | } |
| 316 | 310 | if (is_object($value2) && isset($value2->$property)) { |
| 317 | 311 | $property2 = $value2->$property; |
| 318 | - } |
|
| 319 | - elseif (is_array($value2) && isset($value2[$property])) { |
|
| 312 | + } elseif (is_array($value2) && isset($value2[$property])) { |
|
| 320 | 313 | $property2 = $value2[$property]; |
| 321 | 314 | } |
| 322 | 315 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | public function orderGroups() : array { |
| 99 | 99 | $groups = $this->getGroups(); |
| 100 | 100 | usort($groups, static function($a, $b) { |
| 101 | - return $a->getOrder() - $b->getOrder(); |
|
| 101 | + return $a->getOrder()-$b->getOrder(); |
|
| 102 | 102 | }); |
| 103 | 103 | return $groups; |
| 104 | 104 | } |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | shuffle($teams); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - $split = ceil(count($teams) / count($groups)); |
|
| 158 | + $split = ceil(count($teams)/count($groups)); |
|
| 159 | 159 | foreach ($groups as $where) { |
| 160 | 160 | if (count($teams) > 0) { |
| 161 | 161 | $where->addTeam(...array_splice($teams, 0, $split)); |
@@ -150,8 +150,7 @@ |
||
| 150 | 150 | $teams = $this->getTeams(true, Constants::SEED); |
| 151 | 151 | if ($this::isSeeded($teams)) { |
| 152 | 152 | Functions::sortAlternate($teams); |
| 153 | - } |
|
| 154 | - else { |
|
| 153 | + } else { |
|
| 155 | 154 | shuffle($teams); |
| 156 | 155 | } |
| 157 | 156 | |
@@ -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 | /** |
@@ -73,9 +73,9 @@ discard block |
||
| 73 | 73 | public static function sortAlternate(array &$array) : array { |
| 74 | 74 | $new = []; |
| 75 | 75 | $new2 = []; |
| 76 | - $count = count($array) / 2; |
|
| 76 | + $count = count($array)/2; |
|
| 77 | 77 | for ($i = 0; $i < $count; $i++) { |
| 78 | - if ($i % 2 === 0) { |
|
| 78 | + if ($i%2 === 0) { |
|
| 79 | 79 | $new[] = array_shift($array); |
| 80 | 80 | $new[] = array_pop($array); |
| 81 | 81 | } |
@@ -78,8 +78,7 @@ |
||
| 78 | 78 | if ($i % 2 === 0) { |
| 79 | 79 | $new[] = array_shift($array); |
| 80 | 80 | $new[] = array_pop($array); |
| 81 | - } |
|
| 82 | - else { |
|
| 81 | + } else { |
|
| 83 | 82 | $new2[] = array_shift($array); |
| 84 | 83 | $new2[] = array_pop($array); |
| 85 | 84 | } |
@@ -71,8 +71,7 @@ |
||
| 71 | 71 | /** @infection-ignore-all */ |
| 72 | 72 | $this->id = uniqid('', false); |
| 73 | 73 | throw new InvalidArgumentException('Unsupported id type ('.gettype($id).') - expected type of string or int'); |
| 74 | - } |
|
| 75 | - else { |
|
| 74 | + } else { |
|
| 76 | 75 | $this->id = $id; |
| 77 | 76 | } |
| 78 | 77 | return $this; |