BladeRenderer::render()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace kalanis\kw_table\output_blade;
4
5
6
use kalanis\kw_table\core\Table;
7
use Illuminate\View\Compilers\BladeCompiler;
8
9
10
/**
11
 * Class BladeRenderer
12
 * @package kalanis\kw_table\output_blade
13
 * Direct renderer into template engine Blade (Laravel)
14
 */
15
class BladeRenderer extends Table\AOutput
16
{
17
    protected string $templatePath = '';
18
19
    public function __construct(Table $table)
20
    {
21
        parent::__construct($table);
22
        $this->templatePath = __DIR__ . '/../shared-templates/table.blade.php';
23
    }
24
25
    public function render(): string
26
    {
27
        $source = strval(@file_get_contents($this->templatePath));
28
        return BladeCompiler::render($source, ['table' => $this->table], true);
29
    }
30
}
31