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.

ApiController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 35.9 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 14
loc 39
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A behaviors() 14 14 1
A actions() 0 10 1
A successCallback() 0 4 1
A actionIndex() 0 4 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
namespace app\backend\controllers;
4
5
use app\backend\models\ApiService;
6
use yii\filters\AccessControl;
7
use yii\web\Controller;
8
9
class ApiController extends Controller
10
{
11
12 View Code Duplication
    public function behaviors()
13
    {
14
        return [
15
            'access' => [
16
                'class' => AccessControl::className(),
0 ignored issues
show
Deprecated Code introduced by
The method yii\base\BaseObject::className() has been deprecated with message: since 2.0.14. On PHP >=5.5, use `::class` instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
17
                'rules' => [
18
                    [
19
                        'allow' => true,
20
                        'roles' => ['api manage'],
21
                    ],
22
                ],
23
            ],
24
        ];
25
    }
26
27
    public function actions()
28
    {
29
        return [
30
            'auth' => [
31
                'class' => 'yii\authclient\AuthAction',
32
                'successCallback' => [$this, 'successCallback'],
33
                'clientCollection' => 'apiServiceClientCollection',
34
            ],
35
        ];
36
    }
37
38
    public function successCallback($client)
39
    {
40
        ApiService::saveToken($client->id, $client->accessToken);
41
    }
42
43
    public function actionIndex()
44
    {
45
        return $this->render('index');
46
    }
47
}
48