Passed
Pull Request — development (#671)
by Nick
06:47
created

ChangelogController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A indexAction() 0 14 1
1
<?php
2
3
namespace Oc\Changelog\Controller;
4
5
use League\CommonMark\CommonMarkConverter;
6
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
7
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8
use Symfony\Component\HttpFoundation\Response;
9
use Twig_Environment;
10
11
/**
12
 * Class ChangelogController
13
 *
14
 * @package Oc\Changelog\Controller
15
 *
16
 * @Route(service="Oc\Changelog\Controller\ChangelogController")
17
 */
18
class ChangelogController extends Controller
19
{
20
    /**
21
     * @var CommonMarkConverter
22
     */
23
    private $markConverter;
24
25
    /**
26
     * @var Twig_Environment
27
     */
28
    private $twig;
29
30
    public function __construct(CommonMarkConverter $markConverter, Twig_Environment $twig)
31
    {
32
        $this->markConverter = $markConverter;
33
        $this->twig = $twig;
34
    }
35
36
    /**
37
     * @Route(path="/changelog")
38
     */
39
    public function indexAction()
40
    {
41
        $changelog = $this->markConverter->convertToHtml(file_get_contents(__DIR__ . '/../../../../../ChangeLog-3.1.md'));
42
43
        $response = new Response();
44
        $response->setContent(
45
            $this->twig->render(
46
                'changelog/index.html.twig',
47
                ['changelog' => $changelog]
48
            )
49
        );
50
51
        return $response;
52
    }
53
}
54