RenderView::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.8666
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace Faulancer\View\Helper;
4
5
use Faulancer\Exception\FileNotFoundException;
6
use Faulancer\Exception\ServiceNotFoundException;
7
use Faulancer\View\AbstractViewHelper;
8
use Faulancer\View\ViewController;
9
10
/**
11
 * Class RenderView | RenderView.php
12
 * @package Faulancer\View\Helper
13
 * @author  Florian Knapp <[email protected]>
14
 */
15 View Code Duplication
class RenderView extends AbstractViewHelper
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17
18
    /**
19
     * Render a subview
20
     *
21
     * @param string         $template
22
     * @param array          $variables
23
     * @return string
24
     *
25
     * @throws FileNotFoundException
26
     * @throws ServiceNotFoundException
27
     */
28
    public function __invoke(string $template = '', array $variables = [])
29
    {
30
        $subview = new ViewController();
31
32
        if (!empty($this->view->getTemplatePath())) {
33
            $subview->setTemplatePath($this->view->getTemplatePath());
34
        }
35
36
        $subview->setTemplate( $template );
37
        $subview->setVariables( $variables );
38
        return $subview->render();
39
    }
40
41
}