Controller   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A layoutContent() 0 5 1
A renderOnlyView() 0 5 1
A render() 0 5 1
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