Passed
Push — master ( e6ce91...429907 )
by MusikAnimal
04:46
created

AdminScoreController::resultAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 0
dl 0
loc 13
ccs 0
cts 0
cp 0
crap 2
rs 9.9332
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file contains only the AdminScoreController class.
4
 */
5
6
namespace AppBundle\Controller;
7
8
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
9
use Symfony\Component\HttpFoundation\Request;
10
use Symfony\Component\HttpFoundation\Response;
11
use Xtools\AdminScore;
12
use Xtools\AdminScoreRepository;
13
14
/**
15
 * The AdminScoreController serves the search form and results page of the AdminScore tool.
16
 */
17
class AdminScoreController extends XtoolsController
18
{
19
    /**
20
     * Get the name of the tool's index route.
21
     * @return string
22
     * @codeCoverageIgnore
23
     */
24
    public function getIndexRoute()
25
    {
26
        return 'AdminScore';
27
    }
28
29
    /**
30
     * Display the AdminScore search form.
31
     * @Route("/adminscore", name="AdminScore")
32
     * @Route("/adminscore/", name="AdminScoreSlash")
33
     * @Route("/adminscore/index.php", name="AdminScoreIndexPhp")
34
     * @Route("/scottywong tools/adminscore.php", name="AdminScoreLegacy")
35
     * @Route("/adminscore/{project}", name="AdminScoreProject")
36
     * @return Response
37
     */
38
    public function indexAction()
39
    {
40
        // Redirect if we have a project and user.
41
        if (isset($this->params['project']) && isset($this->params['username'])) {
42
            return $this->redirectToRoute('AdminScoreResult', $this->params);
43
        }
44
45
        return $this->render('adminscore/index.html.twig', [
46
            'xtPage' => 'adminscore',
47
            'xtPageTitle' => 'tool-adminscore',
48
            'xtSubtitle' => 'tool-adminscore-desc',
49
            'project' => $this->project,
50
        ]);
51
    }
52
53
    /**
54
     * Display the AdminScore results.
55
     * @Route("/adminscore/{project}/{username}", name="AdminScoreResult")
56
     * @return Response
57
     * @codeCoverageIgnore
58
     */
59
    public function resultAction()
60
    {
61
        $adminScoreRepo = new AdminScoreRepository();
62
        $adminScoreRepo->setContainer($this->container);
63
        $adminScore = new AdminScore($this->project, $this->user);
64
        $adminScore->setRepository($adminScoreRepo);
65
66
        return $this->render('adminscore/result.html.twig', [
67
            'xtPage' => 'adminscore',
68
            'xtTitle' => $this->user->getUsername(),
69
            'project' => $this->project,
70
            'user' => $this->user,
71
            'as' => $adminScore,
72
        ]);
73
    }
74
}
75