Completed
Push — master ( 27f6d9...d341e0 )
by Michael
03:41
created
src/AppBundle/Controller/UserController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
 
49 49
         return $this->render(
50 50
             'user/index.html.twig',
51
-            ['votes' => $votes, 'user' => $user,]
51
+            ['votes' => $votes, 'user' => $user, ]
52 52
         );
53 53
     }
54 54
 
Please login to merge, or discard this patch.
src/Michaelc/Voting/STV/VoteHandler.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
      *                          	candidate votes)
113 113
      * @return Ballot 	The same ballot passed in modified
114 114
      */
115
-    protected function allocateVotes(Ballot &$ballot, float $multiplier = 1.0, float $divisor = 1.0): Ballot
115
+    protected function allocateVotes(Ballot & $ballot, float $multiplier = 1.0, float $divisor = 1.0): Ballot
116 116
     {
117 117
         $weight = $ballot->setWeight(($ballot->getWeight() * $multiplier) / $divisor);
118 118
         $candidate = $ballot->getNextChoice();
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
             }
223 223
         }
224 224
 
225
-        foreach($minimumCandidates as $minimumCandidate)
225
+        foreach ($minimumCandidates as $minimumCandidate)
226 226
         {
227 227
         	$this->transferEliminatedVotes($minimumCandidate);
228 228
         	$minimumCandidate->setState(Candidate::DEFEATED);
Please login to merge, or discard this patch.
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -61,16 +61,16 @@  discard block
 block discarded – undo
61 61
     {
62 62
         $this->rejectInvalidBallots();
63 63
 
64
-    	$this->firstStep();
64
+        $this->firstStep();
65 65
 
66 66
         $candidates = $this->election->getActiveCandidates();
67 67
 
68 68
         while ($this->electedCandidates < $this->election->getWinnersCount())
69 69
         {
70
-	    	if (!$this->checkCandidates($candidates))
71
-	    	{
72
-	    		$this->eliminateCandidates($candidates);
73
-	    	}
70
+            if (!$this->checkCandidates($candidates))
71
+            {
72
+                $this->eliminateCandidates($candidates);
73
+            }
74 74
         }
75 75
 
76 76
         return $this->election->getElectedCandidates();
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
      */
100 100
     protected function checkCandidates(array &$candidates): bool
101 101
     {
102
-    	foreach ($candidates as $i => $candidate)
102
+        foreach ($candidates as $i => $candidate)
103 103
         {
104 104
             if ($candidate->getVotes() >= $this->quota)
105 105
             {
@@ -127,8 +127,8 @@  discard block
 block discarded – undo
127 127
 
128 128
         if ($candidate !== null)
129 129
         {
130
-	        $this->election->getCandidate($candidate)->addVotes($weight);
131
-	        $ballot->incrementLevelUsed();
130
+            $this->election->getCandidate($candidate)->addVotes($weight);
131
+            $ballot->incrementLevelUsed();
132 132
         }
133 133
 
134 134
         return $ballot;
@@ -144,16 +144,16 @@  discard block
 block discarded – undo
144 144
      */
145 145
     protected function transferSurplusVotes(float $surplus, Candidate $candidate)
146 146
     {
147
-    	$totalVotes = $candiate->getVotes();
148
-    	$candidateId = $candidate->getId();
147
+        $totalVotes = $candiate->getVotes();
148
+        $candidateId = $candidate->getId();
149 149
 
150
-    	foreach ($this->ballots as $i => $ballot)
151
-    	{
152
-        	if ($ballot->getLastChoice()->getId() == $candidateId)
153
-        	{
154
-		        $this->allocateVotes($ballot, $surplus, $totalVotes);
155
-        	}
156
-    	}
150
+        foreach ($this->ballots as $i => $ballot)
151
+        {
152
+            if ($ballot->getLastChoice()->getId() == $candidateId)
153
+            {
154
+                $this->allocateVotes($ballot, $surplus, $totalVotes);
155
+            }
156
+        }
157 157
 
158 158
         return;
159 159
     }
@@ -167,14 +167,14 @@  discard block
 block discarded – undo
167 167
      */
168 168
     protected function transferEliminatedVotes(Candidate $candidate)
169 169
     {
170
-    	$candidateId = $candidate->getId();
170
+        $candidateId = $candidate->getId();
171 171
 
172
-    	foreach ($this->ballots as $i => $ballot)
172
+        foreach ($this->ballots as $i => $ballot)
173 173
         {
174
-        	if ($ballot->getLastChoice()->getId() == $candidateId)
175
-        	{
176
-		        $this->allocateVotes($ballot);
177
-        	}
174
+            if ($ballot->getLastChoice()->getId() == $candidateId)
175
+            {
176
+                $this->allocateVotes($ballot);
177
+            }
178 178
         }
179 179
 
180 180
         return;
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
 
199 199
         if ($this->electedCandidates < $this->election->getWinnersCount())
200 200
         {
201
-        	$surplus = $candidate->getVotes() - $this->quota;
202
-        	$this->transferVotes($surplus, $candidate);
201
+            $surplus = $candidate->getVotes() - $this->quota;
202
+            $this->transferVotes($surplus, $candidate);
203 203
         }
204 204
 
205 205
         return;
@@ -214,9 +214,9 @@  discard block
 block discarded – undo
214 214
      */
215 215
     protected function eliminateCandidates(array &$candidates): int
216 216
     {
217
-    	$minimum = 0;
217
+        $minimum = 0;
218 218
 
219
-    	foreach ($candidates as $i => $candidate)
219
+        foreach ($candidates as $i => $candidate)
220 220
         {
221 221
             if ($candidate->getVotes() > $minimum)
222 222
             {
@@ -232,8 +232,8 @@  discard block
 block discarded – undo
232 232
 
233 233
         foreach($minimumCandidates as $minimumCandidate)
234 234
         {
235
-        	$this->transferEliminatedVotes($minimumCandidate);
236
-        	$minimumCandidate->setState(Candidate::DEFEATED);
235
+            $this->transferEliminatedVotes($minimumCandidate);
236
+            $minimumCandidate->setState(Candidate::DEFEATED);
237 237
         }
238 238
 
239 239
         return count($minimumCandidates);
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -223,8 +223,7 @@  discard block
 block discarded – undo
223 223
                 $minimum = $candidate->getVotes();
224 224
                 unset($minimumCandidates);
225 225
                 $minimumCandidates[] = $candidate;
226
-            }
227
-            elseif ($candidate->getVotes() == $minimum)
226
+            } elseif ($candidate->getVotes() == $minimum)
228 227
             {
229 228
                 $minimumCandidates[] = $candidate;
230 229
             }
@@ -253,8 +252,7 @@  discard block
 block discarded – undo
253 252
             if (count($ballot->getRanking()) > $this->election->getCandidateCount())
254 253
             {
255 254
                 $rejected = true;
256
-            }
257
-            else
255
+            } else
258 256
             {
259 257
                 $candidateIds = $this->election->getCandidateIds();
260 258
 
Please login to merge, or discard this patch.