View   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 34
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getContext() 0 3 2
A existsTemplate() 0 3 1
A render() 0 3 1
A getViewPath() 0 7 2
1
<?php
2
/**
3
 * Automation tool mixed with code generator for easier continuous development
4
 *
5
 * @link      https://github.com/hiqdev/hidev
6
 * @package   hidev
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hidev\components;
12
13
use yii\base\ViewContextInterface;
14
15
/**
16
 * Our View.
17
 */
18
class View extends \yii\base\View implements ViewContextInterface
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public $defaultExtension = 'twig';
24
25
    protected $_viewPath;
26
27
    public function getViewPath()
28
    {
29
        if ($this->_viewPath === null) {
30
            $this->_viewPath = '@hidev/views';
31
        }
32
33
        return $this->_viewPath;
34
    }
35
36
    /**
37
     * Returns rendering context.
38
     */
39
    public function getContext($context = null)
40
    {
41
        return $context ?: $this;
42
    }
43
44
    public function existsTemplate($template, $context = null)
45
    {
46
        return file_exists($this->findViewFile($template, $this->getContext($context)));
47
    }
48
49
    public function render($template, $data = [], $context = null)
50
    {
51
        return parent::render($template, $data, $this->getContext($context));
52
    }
53
}
54