ViewableTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
eloc 8
c 2
b 1
f 0
dl 0
loc 15
ccs 5
cts 6
cp 0.8333
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 8 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace midorikocak\view;
6
7
trait ViewableTrait
8
{
9
    public ?View $view = null;
10
    public string $template = '';
11
12
    abstract public function toArray(): array;
13
14 1
    public function render(): string
15
    {
16 1
        $this->view ??= new View(new FileRenderer());
17 1
        if ($this->template === '') {
18
            return '';
19
        }
20 1
        $this->view->setTemplate($this->template);
21 1
        return $this->view->render($this->toArray());
22
    }
23
}
24