Completed
Push — master ( 23c702...854a8a )
by Andrii
06:07
created

HipanelController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 70
Duplicated Lines 22.86 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 16
loc 70
ccs 0
cts 59
cp 0
rs 10
wmc 2
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A behaviors() 16 16 1
B actions() 0 44 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
/*
4
 * HiPanel core package
5
 *
6
 * @link      https://hipanel.com/
7
 * @package   hipanel-core
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2014-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hipanel\controllers;
13
14
use hipanel\actions\ProxyAction;
15
use hipanel\actions\RedirectAction;
16
use hipanel\actions\RenderAction;
17
use Yii;
18
19
/**
20
 * HiPanel controller.
21
 * Just redirects to dashboard.
22
 */
23
class HipanelController extends \hipanel\base\Controller
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28 View Code Duplication
    public function behaviors()
0 ignored issues
show
Duplication introduced by
This method 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...
29
    {
30
        return [
31
            'access' => [
32
                'class' => 'yii\filters\AccessControl',
33
                'only'  => ['index'],
34
                'rules' => [
35
                    [
36
                        'actions' => ['index'],
37
                        'allow'   => true,
38
                        'roles'   => ['@'],
39
                    ],
40
                ],
41
            ],
42
        ];
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function actions()
49
    {
50
        return [
51
            'index' => [
52
                'class' => RedirectAction::class,
53
                'url'   => ['/dashboard/dashboard'],
54
            ],
55
/// later just for testing
56
            'switch'   => [
57
                'class'      => RenderAction::class,
58
                'addFlash'   => true,
59
                'success'    => Yii::t('app', 'DB truncate task has been created successfully'),
60
                'error'      => Yii::t('app', 'Error while truncating DB'),
61
                'POST html'  => [
62
                    'class'  => ProxyAction::class,
63
                    'action' => 'index',
64
                ],
65
                'GET'        => [
66
                    'class' => RenderAction::class,
67
                    'view'  => 'index',
68
                ],
69
                'POST pjax'  => [
70
                    'class'   => RenderAction::class,
71
                    'view'    => 'index',
72
                ],
73
                'default'    => [
74
                    'class' => RedirectAction::class,
75
                    'url'   => ['index'],
76
                ],
77
            ],
78
            'proxy'    => [
79
                'class'  => ProxyAction::class,
80
                'action' => 'index',
81
            ],
82
            'render'   => [
83
                'class' => RenderAction::class,
84
                'view'  => 'index',
85
            ],
86
            'redirect' => [
87
                'class' => RedirectAction::class,
88
                'url'   => ['index'],
89
            ],
90
        ];
91
    }
92
}
93