Completed
Push — master ( 526007...a3325f )
by Michael
03:04
created
src/AppBundle/Controller/VoteController.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,6 @@
 block discarded – undo
6 6
 use AppBundle\Exception\InvalidSort;
7 7
 use AppBundle\Utils\ElectionManager;
8 8
 use AppBundle\Utils\PollManager;
9
-use AppBundle\Utils\VotableManager;
10 9
 use Pagerfanta\Adapter\ArrayAdapter;
11 10
 use Pagerfanta\Pagerfanta;
12 11
 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
Please login to merge, or discard this patch.
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -17,74 +17,74 @@
 block discarded – undo
17 17
 
18 18
 class VoteController extends Controller
19 19
 {
20
-	private $electionManager;
21
-	private $pollManager;
20
+    private $electionManager;
21
+    private $pollManager;
22 22
 
23
-	/**
24
-	 * VoteController constructor.
25
-	 *
26
-	 * @param \AppBundle\Utils\PollManager     $pollManager
27
-	 * @param \AppBundle\Utils\ElectionManager $electionManager
28
-	 */
29
-	public function __construct(PollManager $pollManager, ElectionManager $electionManager)
30
-	{
31
-		$this->pollManager = $pollManager;
32
-		$this->electionManager = $electionManager;
33
-	}
23
+    /**
24
+     * VoteController constructor.
25
+     *
26
+     * @param \AppBundle\Utils\PollManager     $pollManager
27
+     * @param \AppBundle\Utils\ElectionManager $electionManager
28
+     */
29
+    public function __construct(PollManager $pollManager, ElectionManager $electionManager)
30
+    {
31
+        $this->pollManager = $pollManager;
32
+        $this->electionManager = $electionManager;
33
+    }
34 34
 
35
-	/**
36
-	 * @Route("/polls", name="polls_list")
37
-	 * @param \Symfony\Component\HttpFoundation\Request $request
38
-	 *
39
-	 * @return \Symfony\Component\HttpFoundation\Response
40
-	 * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
41
-	 */
42
-	public function listAction(Request $request): Response
43
-	{
44
-		try {
45
-			$sort = $request->request->has('sort') ? $sort = $request->get('sort') : null;
46
-			$polls = $this->pollManager->getPolls($sort);
47
-			$current = $this->pollManager->getPolls($sort, true);
48
-		} catch ( InvalidSort $e ) {
49
-			throw new NotFoundHttpException('This is an invalid sorting method');
50
-		}
35
+    /**
36
+     * @Route("/polls", name="polls_list")
37
+     * @param \Symfony\Component\HttpFoundation\Request $request
38
+     *
39
+     * @return \Symfony\Component\HttpFoundation\Response
40
+     * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
41
+     */
42
+    public function listAction(Request $request): Response
43
+    {
44
+        try {
45
+            $sort = $request->request->has('sort') ? $sort = $request->get('sort') : null;
46
+            $polls = $this->pollManager->getPolls($sort);
47
+            $current = $this->pollManager->getPolls($sort, true);
48
+        } catch ( InvalidSort $e ) {
49
+            throw new NotFoundHttpException('This is an invalid sorting method');
50
+        }
51 51
 
52
-		$pollsPaginated = $this->paginate($request, $polls);
52
+        $pollsPaginated = $this->paginate($request, $polls);
53 53
 
54
-		return $this->render('default/index.html.twig', ['polls' => $pollsPaginated, 'current' => $current]);
55
-	}
54
+        return $this->render('default/index.html.twig', ['polls' => $pollsPaginated, 'current' => $current]);
55
+    }
56 56
 
57
-	/**
58
-	 * Get pagination object of Polls.
59
-	 *
60
-	 * @param Request $request
61
-	 *
62
-	 * @return Pagerfanta
63
-	 * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
64
-	 */
65
-	protected function paginate(Request $request, array $items): Pagerfanta
66
-	{
67
-		$paginator = new Pagerfanta(new ArrayAdapter($items));
57
+    /**
58
+     * Get pagination object of Polls.
59
+     *
60
+     * @param Request $request
61
+     *
62
+     * @return Pagerfanta
63
+     * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
64
+     */
65
+    protected function paginate(Request $request, array $items): Pagerfanta
66
+    {
67
+        $paginator = new Pagerfanta(new ArrayAdapter($items));
68 68
 
69
-		$paginator->setMaxPerPage(20);
69
+        $paginator->setMaxPerPage(20);
70 70
 
71
-		try {
72
-			$paginator->setCurrentPage($request->query->get('page', 1), false, true);
73
-		} catch ( \PagerFanta\Exception\Exception $e ) {
74
-			throw new NotFoundHttpException('Page not found');
75
-		}
71
+        try {
72
+            $paginator->setCurrentPage($request->query->get('page', 1), false, true);
73
+        } catch ( \PagerFanta\Exception\Exception $e ) {
74
+            throw new NotFoundHttpException('Page not found');
75
+        }
76 76
 
77
-		return $paginator;
78
-	}
77
+        return $paginator;
78
+    }
79 79
 
80
-	/**
81
-	 * @Route("/poll/{id}", name="poll_view")
82
-	 * @param \Symfony\Component\HttpFoundation\Request $request
83
-	 * @param \AppBundle\Entity\Poll                    $poll
84
-	 *
85
-	 * @return \Symfony\Component\HttpFoundation\Response
86
-	 */
87
-	public function viewAction(Request $request, Poll $poll): Response
88
-	{
89
-	}
80
+    /**
81
+     * @Route("/poll/{id}", name="poll_view")
82
+     * @param \Symfony\Component\HttpFoundation\Request $request
83
+     * @param \AppBundle\Entity\Poll                    $poll
84
+     *
85
+     * @return \Symfony\Component\HttpFoundation\Response
86
+     */
87
+    public function viewAction(Request $request, Poll $poll): Response
88
+    {
89
+    }
90 90
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 			$sort = $request->request->has('sort') ? $sort = $request->get('sort') : null;
46 46
 			$polls = $this->pollManager->getPolls($sort);
47 47
 			$current = $this->pollManager->getPolls($sort, true);
48
-		} catch ( InvalidSort $e ) {
48
+		} catch (InvalidSort $e) {
49 49
 			throw new NotFoundHttpException('This is an invalid sorting method');
50 50
 		}
51 51
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
 		try {
72 72
 			$paginator->setCurrentPage($request->query->get('page', 1), false, true);
73
-		} catch ( \PagerFanta\Exception\Exception $e ) {
73
+		} catch (\PagerFanta\Exception\Exception $e) {
74 74
 			throw new NotFoundHttpException('Page not found');
75 75
 		}
76 76
 
Please login to merge, or discard this patch.
src/AppBundle/Utils/ElectionManager.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -3,22 +3,22 @@  discard block
 block discarded – undo
3 3
 namespace AppBundle\Utils;
4 4
 
5 5
 use AppBundle\Entity\{
6
-	Choice, Poll
6
+    Choice, Poll
7 7
 };
8 8
 use Doctrine\Common\Persistence\ManagerRegistry;
9 9
 
10 10
 class ElectionManager
11 11
 {
12
-	private $doctrineRegistry;
13
-
14
-	/**
15
-	 * Constructor.
16
-	 *
17
-	 * @param \Doctrine\Common\Persistence\ManagerRegistry $doctrineRegistry
18
-	 */
19
-	public function __construct(ManagerRegistry $doctrineRegistry)
12
+    private $doctrineRegistry;
13
+
14
+    /**
15
+     * Constructor.
16
+     *
17
+     * @param \Doctrine\Common\Persistence\ManagerRegistry $doctrineRegistry
18
+     */
19
+    public function __construct(ManagerRegistry $doctrineRegistry)
20 20
     {
21
-	    $this->doctrineRegistry = $doctrineRegistry;
21
+        $this->doctrineRegistry = $doctrineRegistry;
22 22
     }
23 23
 
24 24
     public function isElection(Poll $poll): boolean
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
33 33
 
34 34
     public function calculateElectionResult(Poll $poll): array
35 35
     {
36
-	    return $this->getElectionResults($poll);
36
+        return $this->getElectionResults($poll);
37 37
     }
38 38
 
39
-	public function getElectionResults(Poll $poll): array
40
-	{
41
-		return [];
42
-	}
39
+    public function getElectionResults(Poll $poll): array
40
+    {
41
+        return [];
42
+    }
43 43
 
44 44
     public function submitVotes(array $choices)
45 45
     {
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         return [];
52 52
     }
53 53
 
54
-	public function getElectionWinner(Poll $poll): Choice
54
+    public function getElectionWinner(Poll $poll): Choice
55 55
     {
56 56
         return;
57 57
     }
Please login to merge, or discard this patch.
src/AppBundle/Utils/PollManager.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 namespace AppBundle\Utils;
4 4
 
5 5
 use AppBundle\Entity\{
6
-	Choice, Poll, PollType
6
+    Choice, Poll, PollType
7 7
 };
8 8
 use Doctrine\Common\Persistence\ManagerRegistry;
9 9
 
@@ -12,24 +12,24 @@  discard block
 block discarded – undo
12 12
     protected $doctrineRegistry;
13 13
     protected $electionManager;
14 14
 
15
-	/**
16
-	 * Constructor.
17
-	 *
18
-	 * @param \Doctrine\Common\Persistence\ManagerRegistry $doctrineRegistry
19
-	 * @param \AppBundle\Utils\ElectionManager             $electionManager
20
-	 */
21
-	public function __construct(ManagerRegistry $doctrineRegistry, ElectionManager $electionManager)
15
+    /**
16
+     * Constructor.
17
+     *
18
+     * @param \Doctrine\Common\Persistence\ManagerRegistry $doctrineRegistry
19
+     * @param \AppBundle\Utils\ElectionManager             $electionManager
20
+     */
21
+    public function __construct(ManagerRegistry $doctrineRegistry, ElectionManager $electionManager)
22 22
     {
23 23
         $this->doctrineRegistry = $doctrineRegistry;
24 24
         $this->electionManager = $electionManager;
25 25
     }
26 26
 
27
-	public function getPolls($sort, boolean $current = false): array
28
-	{
29
-		if ($current) {
30
-			return $this->getCurrentPolls();
31
-		}
32
-	}
27
+    public function getPolls($sort, boolean $current = false): array
28
+    {
29
+        if ($current) {
30
+            return $this->getCurrentPolls();
31
+        }
32
+    }
33 33
 
34 34
     /**
35 35
      * Get an array of current polls (objects).
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function getAllPolls(): array
64 64
     {
65
-	    $polls = $this->doctrineRegistry->getEntityManager()->getRepository('AppBundle:Poll')->findAll();
65
+        $polls = $this->doctrineRegistry->getEntityManager()->getRepository('AppBundle:Poll')->findAll();
66 66
 
67 67
         return $polls;
68 68
     }
@@ -82,13 +82,13 @@  discard block
 block discarded – undo
82 82
         return [];
83 83
     }
84 84
 
85
-	/**
86
-	 * Get the result of the poll (in terms of a choice).
87
-	 *
88
-	 * @param Poll $poll
89
-	 *
90
-	 * @return \AppBundle\Entity\Choice
91
-	 */
85
+    /**
86
+     * Get the result of the poll (in terms of a choice).
87
+     *
88
+     * @param Poll $poll
89
+     *
90
+     * @return \AppBundle\Entity\Choice
91
+     */
92 92
     public function getPollResult(Poll $poll): Choice
93 93
     {
94 94
         // If election then call Election Manager
Please login to merge, or discard this patch.