GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ActionColumn   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 51.06 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 24
loc 47
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A initDefaultButtons() 24 41 4

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
namespace app\components;
4
5
use kartik\icons\Icon;
6
use Yii;
7
use yii\helpers\Html;
8
9
class ActionColumn extends \yii\grid\ActionColumn
10
{
11
    /**
12
    * Initializes the default button rendering callbacks
13
    */
14
    protected function initDefaultButtons()
15
    {
16 View Code Duplication
        if (!isset($this->buttons['view'])) {
17
            $this->buttons['view'] = function ($url, $model) {
0 ignored issues
show
Unused Code introduced by
The parameter $model is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
18
                return Html::a(
19
                    Icon::show('eye', ['class' => 'fa-lg'], Icon::FA),
20
                    $url,
21
                    [
22
                        'title' => \Yii::t('yii', 'View'),
23
                        'data-pjax' => '0',
24
                    ]
25
                );
26
            };
27
        }
28 View Code Duplication
        if (!isset($this->buttons['update'])) {
29
            $this->buttons['update'] = function ($url, $model) {
0 ignored issues
show
Unused Code introduced by
The parameter $model is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
30
                return Html::a(
31
                    Icon::show('edit', ['class' => 'fa-lg'], Icon::FA),
32
                    $url,
33
                    [
34
                        'title' => \Yii::t('yii', 'Update'),
35
                        'data-pjax' => '0',
36
                    ]
37
                );
38
            };
39
        }
40
        if (!isset($this->buttons['delete'])) {
41
            $this->buttons['delete'] = function ($url, $model) {
0 ignored issues
show
Unused Code introduced by
The parameter $model is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42
                return Html::a(
43
                    Icon::show('trash-o', ['class' => 'fa-lg'], Icon::FA),
44
                    $url,
45
                    [
46
                        'title' => \Yii::t('yii', 'Delete'),
47
                        'data-confirm' => \Yii::t('yii', 'Are you sure to delete this item?'),
48
                        'data-method' => 'post',
49
                        'data-pjax' => '0',
50
                    ]
51
                );
52
            };
53
        }
54
    }
55
}
56