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

TemplateResponse   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A getTemplate() 0 3 1
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