Failed Conditions
Push — ng ( 58acea...0d961a )
by Florent
14:03
created

TwigFormPostResponseRenderer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\Bundle\Service;
15
16
use OAuth2Framework\Component\AuthorizationEndpoint\ResponseMode\FormPostResponseRenderer;
17
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
18
19
final class TwigFormPostResponseRenderer implements FormPostResponseRenderer
20
{
21
    /**
22
     * @var EngineInterface
23
     */
24
    private $templateEngine;
25
26
    /**
27
     * @var string
28
     */
29
    private $template;
30
31
    /**
32
     * FormPostResponseMode constructor.
33
     *
34
     * @param EngineInterface $templateEngine
35
     * @param string          $template
36
     */
37
    public function __construct(EngineInterface $templateEngine, string $template)
38
    {
39
        $this->templateEngine = $templateEngine;
40
        $this->template = $template;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function render(string $redirect_uri, array $data): string
47
    {
48
        return $this->templateEngine->render(
49
            $this->template,
50
            [
51
                'redirect_uri' => $redirect_uri,
52
                'inputs' => $data,
53
            ]
54
        );
55
    }
56
}
57