ParentTemplate::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Faulancer\View\Helper;
4
5
use Faulancer\Exception\FileNotFoundException;
6
use Faulancer\View\AbstractViewHelper;
7
use Faulancer\View\ViewController;
8
9
/**
10
 * Class ParentTemplate
11
 *
12
 * @package Faulancer\View\Helper
13
 * @author  Florian Knapp <[email protected]>
14
 */
15 View Code Duplication
class ParentTemplate 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
     * Define the parent template
20
     *
21
     * @param string $template
22
     *
23
     * @throws FileNotFoundException
24
     */
25
    public function __invoke(string $template = '')
26
    {
27
        $viewParent = new ViewController();
28
29
        if (!empty($this->getView()->getTemplatePath())) {
30
            $viewParent->setTemplatePath($this->view->getTemplatePath());
31
        }
32
33
        $viewParent->setTemplate($template);
34
        $this->view->setParentTemplate($viewParent);
35
    }
36
37
}