@@ -48,7 +48,7 @@ |
||
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 |
@@ -2,8 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace AppBundle\Utils; |
4 | 4 | |
5 | -use Doctrine\ORM\EntityManager; |
|
6 | 5 | use AppBundle\Entity\Poll; |
6 | +use Doctrine\ORM\EntityManager; |
|
7 | 7 | |
8 | 8 | class PollManager |
9 | 9 | { |
@@ -11,19 +11,19 @@ discard block |
||
11 | 11 | protected $pollRepo; |
12 | 12 | protected $electionManager; |
13 | 13 | |
14 | - /** |
|
15 | - * Constructor |
|
16 | - * |
|
17 | - * @param EntityManager $entityManager |
|
18 | - */ |
|
19 | - public function __construct(EntityManager $entityManager, ElectionManager $electionManager) |
|
20 | - { |
|
21 | - $this->entityManager = $entityManager; |
|
22 | - $this->repo = $this->entityManager->getRepository('AppBundle:Poll'); |
|
14 | + /** |
|
15 | + * Constructor |
|
16 | + * |
|
17 | + * @param EntityManager $entityManager |
|
18 | + */ |
|
19 | + public function __construct(EntityManager $entityManager, ElectionManager $electionManager) |
|
20 | + { |
|
21 | + $this->entityManager = $entityManager; |
|
22 | + $this->repo = $this->entityManager->getRepository('AppBundle:Poll'); |
|
23 | 23 | $this->electionManager = $electionManager; |
24 | - } |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
26 | + /** |
|
27 | 27 | * Get an array of current polls (objects) |
28 | 28 | * |
29 | 29 | * @return array |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function getEligibleVoters(PollType $type): array |
45 | 45 | { |
46 | - return []; |
|
46 | + return []; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function getAllPolls(): array |
55 | 55 | { |
56 | - $polls = $this->repo->findAll(); |
|
56 | + $polls = $this->repo->findAll(); |
|
57 | 57 | |
58 | - return $polls; |
|
58 | + return $polls; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function getPollStats(Poll $poll): array |
68 | 68 | { |
69 | - // If Poll is election then reject |
|
69 | + // If Poll is election then reject |
|
70 | 70 | |
71 | - // Get standard stats |
|
72 | - return []; |
|
71 | + // Get standard stats |
|
72 | + return []; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -80,19 +80,19 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function getPollResult(Poll $poll): Choice |
82 | 82 | { |
83 | - // If election then call Election Manager |
|
83 | + // If election then call Election Manager |
|
84 | 84 | |
85 | - // Calculate winning choice |
|
86 | - return; |
|
85 | + // Calculate winning choice |
|
86 | + return; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | public function getStandardPollVotes(Poll $poll): array |
90 | 90 | { |
91 | - return []; |
|
91 | + return []; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | public function markPollClosed(Poll $poll) |
95 | 95 | { |
96 | - return; |
|
96 | + return; |
|
97 | 97 | } |
98 | 98 | } |
@@ -4,16 +4,16 @@ |
||
4 | 4 | |
5 | 5 | class Election |
6 | 6 | { |
7 | - protected $candidateCount; |
|
8 | - protected $winnersCount; |
|
7 | + protected $candidateCount; |
|
8 | + protected $winnersCount; |
|
9 | 9 | |
10 | - protected $candidates; |
|
11 | - protected $ballots; |
|
10 | + protected $candidates; |
|
11 | + protected $ballots; |
|
12 | 12 | |
13 | - public function __construct(int $winnersCount, array $candidates, array $ballots) |
|
14 | - { |
|
15 | - $this->winnersCount = $winnersCount; |
|
16 | - $this->candidates = $candidates; |
|
17 | - $this->ballots = $ballots; |
|
18 | - } |
|
13 | + public function __construct(int $winnersCount, array $candidates, array $ballots) |
|
14 | + { |
|
15 | + $this->winnersCount = $winnersCount; |
|
16 | + $this->candidates = $candidates; |
|
17 | + $this->ballots = $ballots; |
|
18 | + } |
|
19 | 19 | } |
@@ -4,38 +4,38 @@ |
||
4 | 4 | |
5 | 5 | class Ballot |
6 | 6 | { |
7 | - /** |
|
8 | - * Ranking of candidates ids |
|
9 | - * |
|
10 | - * @var array |
|
11 | - */ |
|
12 | - protected $ranking; |
|
7 | + /** |
|
8 | + * Ranking of candidates ids |
|
9 | + * |
|
10 | + * @var array |
|
11 | + */ |
|
12 | + protected $ranking; |
|
13 | 13 | |
14 | - /** |
|
15 | - * The current weighting or value of this person's vote |
|
16 | - * |
|
17 | - * @var float |
|
18 | - */ |
|
19 | - protected $weight; |
|
14 | + /** |
|
15 | + * The current weighting or value of this person's vote |
|
16 | + * |
|
17 | + * @var float |
|
18 | + */ |
|
19 | + protected $weight; |
|
20 | 20 | |
21 | - /** |
|
22 | - * The current preference in use from this ballot |
|
23 | - * |
|
24 | - * @var integer |
|
25 | - */ |
|
26 | - protected $levelUsed; |
|
21 | + /** |
|
22 | + * The current preference in use from this ballot |
|
23 | + * |
|
24 | + * @var integer |
|
25 | + */ |
|
26 | + protected $levelUsed; |
|
27 | 27 | |
28 | - /** |
|
29 | - * Constructor |
|
30 | - * |
|
31 | - * @param array $ranking The ranking of candidates Key being ranking, |
|
32 | - * value being a candidate id |
|
33 | - */ |
|
34 | - public function __construct(array $ranking) |
|
35 | - { |
|
36 | - $this->weight = 1.0; |
|
37 | - $this->ranking = $ranking; |
|
38 | - $this->levelUsed = 0; |
|
28 | + /** |
|
29 | + * Constructor |
|
30 | + * |
|
31 | + * @param array $ranking The ranking of candidates Key being ranking, |
|
32 | + * value being a candidate id |
|
33 | + */ |
|
34 | + public function __construct(array $ranking) |
|
35 | + { |
|
36 | + $this->weight = 1.0; |
|
37 | + $this->ranking = $ranking; |
|
38 | + $this->levelUsed = 0; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -4,19 +4,19 @@ |
||
4 | 4 | |
5 | 5 | class Candidate |
6 | 6 | { |
7 | - const ELECTED = 1; |
|
8 | - const RUNNING = 2; |
|
9 | - const DEFEATED = 3; |
|
7 | + const ELECTED = 1; |
|
8 | + const RUNNING = 2; |
|
9 | + const DEFEATED = 3; |
|
10 | 10 | |
11 | - protected $id; |
|
12 | - protected $votes; |
|
13 | - protected $surplus; |
|
14 | - protected $state; |
|
11 | + protected $id; |
|
12 | + protected $votes; |
|
13 | + protected $surplus; |
|
14 | + protected $state; |
|
15 | 15 | |
16 | - function __construct() |
|
17 | - { |
|
18 | - $this->votes = 0; |
|
19 | - $this->surplus = 0; |
|
20 | - $this->state = self::RUNNING; |
|
21 | - } |
|
16 | + function __construct() |
|
17 | + { |
|
18 | + $this->votes = 0; |
|
19 | + $this->surplus = 0; |
|
20 | + $this->state = self::RUNNING; |
|
21 | + } |
|
22 | 22 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | public function calculateElectionResult(Poll $poll): array |
35 | 35 | { |
36 | - return getElectionResults($poll); |
|
36 | + return getElectionResults($poll); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | public function submitVotes(array $choices) |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | |
44 | 44 | public function getElectionPollVotes(Poll $poll): array |
45 | 45 | { |
46 | - return []; |
|
46 | + return []; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | public function getElectionResults(Poll $poll): array |
50 | 50 | { |
51 | - return []; |
|
51 | + return []; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | public function getElectionWinner(Poll $poll): AppBundle\Entity\Choice |
@@ -2,8 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace AppBundle\Utils; |
4 | 4 | |
5 | -use Doctrine\ORM\EntityManager; |
|
6 | 5 | use AppBundle\Entity\Poll; |
6 | +use Doctrine\ORM\EntityManager; |
|
7 | 7 | |
8 | 8 | class PollManager |
9 | 9 | { |