Completed
Push — master ( ba3348...fd1fa4 )
by Midori
03:53 queued 02:40
created

ViewableTrait::render()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 2
nc 2
nop 0
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
    public function render(): string
13
    {
14
        $this->view ??= new View(new FileRenderer());
15
        if ($this->template === '') {
16
            return '';
17
        }
18
        $this->view->setTemplate($this->template);
19
        return $this->view->render($this->toArray());
0 ignored issues
show
Bug introduced by
It seems like toArray() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
        return $this->view->render($this->/** @scrutinizer ignore-call */ toArray());
Loading history...
20
    }
21
}
22