TwigBuilder   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getBody() 0 7 1
1
<?php
2
/**
3
 * This file is part of the Divergence package.
4
 *
5
 * (c) Henry Paradiz <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Divergence\Responders;
12
13
use Divergence\App;
14
use Twig\Environment;
15
use GuzzleHttp\Psr7\Utils;
16
use Twig\Loader\FilesystemLoader;
17
use Psr\Http\Message\StreamInterface;
18
use Twig\Extension\StringLoaderExtension;
19
20
class TwigBuilder extends ResponseBuilder
21
{
22
    protected string $contentType = 'text/html; charset=utf-8';
23
24 4
    public function getBody(): StreamInterface
25
    {
26 4
        $loader = new FilesystemLoader([App::$App->ApplicationPath.'/views']);
27 4
        $env = new Environment($loader, ['strict_variables' => true]);
28 4
        $env->addExtension(new StringLoaderExtension());
29 4
        $output = $env->render($this->template, $this->data);
30 1
        return Utils::streamFor($output);
31
    }
32
}
33