Passed
Push — master ( 0ac9a3...3f373d )
by Yohann
02:09
created

Controller::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 5
rs 10
1
<?php
2
3
namespace mvc\core\meta;
4
5
abstract class Controller
6
{
7
    public function render($view, $params = []): string
8
    {
9
        $layoutContent = $this->layoutContent();
10
        $viewContent = $this->renderOnlyView($view, $params);
11
        return str_replace('{{content}}', $viewContent, $layoutContent);
12
    }
13
14
    public function layoutContent(): string
15
    {
16
        ob_start();
17
        include_once ROOT_DIR . "/app/views/layouts/base.php";
18
        return ob_get_clean();
19
    }
20
21
    protected function renderOnlyView($view, $data): string
0 ignored issues
show
Unused Code introduced by
The parameter $data is not used and could be removed. ( Ignorable by Annotation )

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

21
    protected function renderOnlyView($view, /** @scrutinizer ignore-unused */ $data): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
    {
23
        ob_start();
24
        include_once ROOT_DIR . "/app/views/pages/$view.php";
25
        return ob_get_clean();
26
    }
27
}
28