Completed
Push — master ( 375de1...c13e1e )
by Andrii
13:21
created

Component   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 3
dl 20
loc 20
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 8 8 1
A getViewPath() 6 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hidev\base;
12
13
use ReflectionClass;
14
use Yii;
15
use yii\base\ViewContextInterface;
16
17
/**
18
 * Base for components.
19
 */
20 View Code Duplication
class Component extends \yii\base\Component implements ViewContextInterface
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...
21
{
22
    use GettersTrait;
23
24
    public function render($view, $params = [])
25
    {
26
        return Yii::$app->getView()->render($view, array_merge([
27
            'app' => Yii::$app,
28
            'config' => Yii::$app,
29
            'component' => $this,
30
        ], $params), $this);
31
    }
32
33
    public function getViewPath()
34
    {
35
        $ref = new ReflectionClass($this);
36
37
        return dirname(dirname($ref->getFileName())) . '/views';
38
    }
39
}
40