Completed
Push — master ( 5432fb...a44a55 )
by Peter
22:26
created

PsrController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 37
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A indexAction() 0 6 1
A showAction() 0 14 2
1
<?php
2
3
namespace AppBundle\Controller;
4
5
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7
use Symfony\Component\HttpFoundation\Response;
8
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
9
10
11
/**
12
 * Slovenian translation of PHP Standards Recommendations.
13
 *
14
 * @Route("/psr")
15
 */
16
class PsrController extends Controller
17
{
18
    /**
19
     * @Route("", name="psr_index")
20
     * @Cache(maxage="20", public=true)
21
     *
22
     * @return Response
23
     */
24
    public function indexAction()
25
    {
26
        return $this->render('psr/index.html.twig', [
27
            'psrs' => $this->get('app.repository.psr')->findAll()
28
        ]);
29
    }
30
31
    /**
32
     * @Route("/{slug}", name="psr_show")
33
     * @Cache(maxage="20", public=true)
34
     *
35
     * @param string $slug
36
     * @return Response
37
     */
38
    public function showAction($slug)
39
    {
40
        $psr = $this->get('app.repository.psr')->findOneBySlug($slug);
41
42
        if (!$psr) {
43
            throw $this->createNotFoundException(
44
                'No PSR found for slug '.$slug
45
            );
46
        }
47
48
        return $this->render('psr/show.html.twig', [
49
            'psr' => $psr
50
        ]);
51
    }
52
}
53