LatteRenderer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 1
b 0
f 0
dl 0
loc 16
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A render() 0 6 1
1
<?php
2
3
namespace kalanis\kw_table\output_latte;
4
5
6
use kalanis\kw_table\core\Table;
7
use Latte\Engine;
8
9
10
/**
11
 * Class LatteRenderer
12
 * @package kalanis\kw_table\output_latte
13
 * Render output in html templates from Nette\Latte
14
 * @link https://latte.nette.org/en/guide
15
 */
16
class LatteRenderer extends Table\AOutput
17
{
18
    protected Engine $engine = null;
19
20
    public function __construct(Table $table)
21
    {
22
        parent::__construct($table);
23
        $this->engine = new Engine();
24
    }
25
26
    public function render(): string
27
    {
28
        return $this->engine->renderToString(
29
            realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'shared-templates' . DIRECTORY_SEPARATOR . 'table.latte'),
30
            [
31
                'table' => $this->table,
32
            ]
33
        );
34
    }
35
}
36