Completed
Pull Request — master (#90)
by Arnaud
02:00
created

AbstractResponder::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace LAG\AdminBundle\Action\Responder;
4
5
use Symfony\Component\HttpFoundation\Response;
6
use Symfony\Component\Routing\RouterInterface;
7
use Twig_Environment;
8
9
abstract class AbstractResponder
10
{
11
    /**
12
     * @var RouterInterface
13
     */
14
    protected $router;
15
    
16
    /**
17
     * @var Twig_Environment
18
     */
19
    protected $twig;
20
    
21
    /**
22
     * AbstractResponder constructor.
23
     *
24
     * @param RouterInterface  $router
25
     * @param Twig_Environment $twig
26
     */
27 9
    public function __construct(RouterInterface $router, Twig_Environment $twig)
28
    {
29 9
        $this->router = $router;
30 9
        $this->twig = $twig;
31 9
    }
32
    
33
    /**
34
     * Create a Response with a Twig rendered content.
35
     *
36
     * @param string $template
37
     * @param array  $context
38
     *
39
     * @return Response
40
     */
41 4
    protected function render($template, array $context = [])
42
    {
43
        $content =  $this
44 4
            ->twig
45 4
            ->render($template, $context)
46
        ;
47
        
48 4
        return new Response($content);
49
    }
50
}
51