Completed
Push — master ( 0a3a64...75d382 )
by Julien
02:47
created
src/Models/DirectEliminationFight.php 2 patches
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -2,9 +2,6 @@
 block discarded – undo
2 2
 
3 3
 namespace Xoco70\KendoTournaments\Models;
4 4
 
5
-use Illuminate\Database\Eloquent\Model;
6
-use Illuminate\Support\Collection;
7
-
8 5
 class DirectEliminationFight extends Fight
9 6
 {
10 7
     public function __construct(Fight $fight = null)
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@
 block discarded – undo
9 9
 {
10 10
     public function __construct(Fight $fight = null)
11 11
     {
12
-        if ($fight!=null){
13
-            $this->id= $fight->id;
14
-            $this->short_id= $fight->short_id;
15
-            $this->fighters_group_id= $fight->fighters_group_id;
16
-            $this->c1= $fight->c1;
17
-            $this->c2= $fight->c2;
12
+        if ($fight != null) {
13
+            $this->id = $fight->id;
14
+            $this->short_id = $fight->short_id;
15
+            $this->fighters_group_id = $fight->fighters_group_id;
16
+            $this->c1 = $fight->c1;
17
+            $this->c2 = $fight->c2;
18 18
         }
19 19
     }
20 20
     /**
Please login to merge, or discard this patch.
src/TreeGen/TreeGen.php 3 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -8,10 +8,8 @@
 block discarded – undo
8 8
 use Xoco70\KendoTournaments\Exceptions\TreeGenerationException;
9 9
 use Xoco70\KendoTournaments\Models\Championship;
10 10
 use Xoco70\KendoTournaments\Models\ChampionshipSettings;
11
-use Xoco70\KendoTournaments\Models\DirectEliminationFight;
12 11
 use Xoco70\KendoTournaments\Models\Fight;
13 12
 use Xoco70\KendoTournaments\Models\FightersGroup;
14
-use Xoco70\KendoTournaments\Models\PreliminaryFight;
15 13
 
16 14
 class TreeGen implements TreeGenerable
17 15
 {
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     private function getMaxFightersByEntity($userGroups): int
62 62
     {
63 63
         return $userGroups
64
-            ->sortByDesc(function ($group) {
64
+            ->sortByDesc(function($group) {
65 65
                 return $group->count();
66 66
             })
67 67
             ->first()
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     protected function getTreeSize($fighterCount, $groupSize)
100 100
     {
101 101
         $square = collect([1, 2, 4, 8, 16, 32, 64]);
102
-        $squareMultiplied = $square->map(function ($item) use ($groupSize) {
102
+        $squareMultiplied = $square->map(function($item) use ($groupSize) {
103 103
             return $item * $groupSize;
104 104
         });
105 105
 
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
             $valueToUpdate = $group->getValueToUpdate(); // This should be OK
412 412
             if ($valueToUpdate != null) {
413 413
                 $fighterToUpdate = $group->getParentFighterToUpdate($keyGroup);
414
-                dump("key:".$keyGroup."-".$fighterToUpdate."=>".$valueToUpdate);
414
+                dump("key:" . $keyGroup . "-" . $fighterToUpdate . "=>" . $valueToUpdate);
415 415
                 $parentFight->$fighterToUpdate = $valueToUpdate;
416 416
                 $parentFight->save();
417 417
             }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -392,7 +392,9 @@
 block discarded – undo
392 392
     {
393 393
         foreach ($groupsByRound as $keyGroup => $group) {
394 394
             $parentGroup = $group->parent;
395
-            if ($parentGroup == null) break;
395
+            if ($parentGroup == null) {
396
+                break;
397
+            }
396 398
             $parentFight = $parentGroup->fights->get(0);
397 399
 
398 400
             // determine whether c1 or c2 must be updated
Please login to merge, or discard this patch.
src/Models/PreliminaryFight.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@
 block discarded – undo
9 9
 
10 10
     public function __construct(Fight $fight = null)
11 11
     {
12
-        if ($fight!=null){
13
-            $this->id= $fight->id;
14
-            $this->short_id= $fight->short_id;
15
-            $this->fighters_group_id= $fight->fighters_group_id;
16
-            $this->c1= $fight->c1;
17
-            $this->c2= $fight->c2;
12
+        if ($fight != null) {
13
+            $this->id = $fight->id;
14
+            $this->short_id = $fight->short_id;
15
+            $this->fighters_group_id = $fight->fighters_group_id;
16
+            $this->c1 = $fight->c1;
17
+            $this->c2 = $fight->c2;
18 18
         }
19 19
     }
20 20
 
Please login to merge, or discard this patch.
src/models/FightersGroup.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -180,7 +180,7 @@
 block discarded – undo
180 180
     public function hasDeterminedParent()
181 181
     {
182 182
         // There is more than 1 fight, should be Preliminary
183
-        if (sizeof($this->fighters()) > 1){
183
+        if (sizeof($this->fighters()) > 1) {
184 184
             return false;
185 185
         }
186 186
         foreach ($this->children as $child) {
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -184,7 +184,9 @@
 block discarded – undo
184 184
             return false;
185 185
         }
186 186
         foreach ($this->children as $child) {
187
-            if (sizeof($child->fighters()) > 1) return false;
187
+            if (sizeof($child->fighters()) > 1) {
188
+                return false;
189
+            }
188 190
         }
189 191
         return true;
190 192
 
Please login to merge, or discard this patch.
src/models/Fight.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -46,7 +46,9 @@  discard block
 block discarded – undo
46 46
      */
47 47
     protected static function getFightersWithByes(FightersGroup $group)
48 48
     {
49
-        if ($group == null) return null;
49
+        if ($group == null) {
50
+            return null;
51
+        }
50 52
         $fighters = $group->getFighters();
51 53
         $fighterType = $group->getFighterType();
52 54
         if (sizeof($fighters) == 0) {
@@ -121,8 +123,12 @@  discard block
 block discarded – undo
121 123
 
122 124
     public function shouldBeInFightList()
123 125
     {
124
-        if ($this->belongsToFirstRound() && $this->dontHave2Fighters()) return false;
125
-        if ($this->has2Fighters()) return true;
126
+        if ($this->belongsToFirstRound() && $this->dontHave2Fighters()) {
127
+            return false;
128
+        }
129
+        if ($this->has2Fighters()) {
130
+            return true;
131
+        }
126 132
         // We aint in the first round, and there is 1 or 0 competitor
127 133
         // We check children, and see :
128 134
         // if there is 2  - 2 fighters -> undetermine, we cannot add it to fight list
@@ -148,7 +154,9 @@  discard block
 block discarded – undo
148 154
     private function belongsToFirstRound()
149 155
     {
150 156
         $firstRoundFights = $this->group->championship->firstRoundFights->pluck('id')->toArray();
151
-        if (in_array($this->id, $firstRoundFights)) return true;
157
+        if (in_array($this->id, $firstRoundFights)) {
158
+            return true;
159
+        }
152 160
         return false;
153 161
     }
154 162
 
Please login to merge, or discard this patch.