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

ViewableTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 8
c 1
b 0
f 0
dl 0
loc 13
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
    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