Test Failed
Push — develop ( 50f9bb...e90cf2 )
by nguereza
02:33
created

TemplateResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 5
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * To change this license header, choose License Headers in Project Properties.
5
 * To change this template file, choose Tools | Templates
6
 * and open the template in the editor.
7
 */
8
9
namespace Platine\Framework\Demo\Response;
10
11
use Platine\Http\Response;
12
use Platine\Template\Template;
13
14
/**
15
 * Description of TemplateResponse
16
 *
17
 * @author tony
18
 */
19
class TemplateResponse extends Response
20
{
21
22
    protected Template $template;
23
24
    /**
25
     * Create new instance
26
     * @param Template $template
27
     * @param string $name
28
     * @param array<string, mixed> $context
29
     * @param int $statusCode
30
     * @param string $reasonPhrase
31
     */
32
    public function __construct(
33
        Template $template,
34
        string $name,
35
        array $context = [],
36
        int $statusCode = 200,
37
        string $reasonPhrase = ''
38
    ) {
39
        parent::__construct($statusCode, $reasonPhrase);
40
        $this->getBody()->write($template->render($name, $context));
41
    }
42
43
    /**
44
     * Return the template instance
45
     * @return Template
46
     */
47
    public function getTemplate(): Template
48
    {
49
        return $this->template;
50
    }
51
}
52