Issues (480)

src/View/Template/Render.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 *
4
 */
5
6
namespace Mvc5\View\Template;
7
8
use Mvc5\Template\TemplateModel;
9
use Mvc5\View\ViewEngine;
10
11
trait Render
12
{
13
    /**
14
     *
15
     */
16
    use Traverse;
17
18
    /**
19
     * @var ViewEngine
20
     */
21
    protected ViewEngine $engine;
22
23
    /**
24
     * @param array|string|TemplateModel $template
25
     * @param array $vars
26
     * @return string
27
     */
28 9
    function render($template, array $vars = []) : string
29
    {
30 9
        return $this->engine->render($this->traverse($this->model($template, $vars)));
0 ignored issues
show
It seems like model() 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

30
        return $this->engine->render($this->traverse($this->/** @scrutinizer ignore-call */ model($template, $vars)));
Loading history...
31
    }
32
33
    /**
34
     * @param TemplateModel|mixed $model
35
     * @param array $vars
36
     * @return string|mixed
37
     */
38 4
    function __invoke($model = null, array $vars = [])
39
    {
40 4
        return !$model instanceof TemplateModel ? $model : $this->render($model, $vars);
41
    }
42
}
43