BladeRenderer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A render() 0 4 1
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