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.
Test Setup Failed
Push — google-feed ( 5c4917...aa2c4e )
by
unknown
16:17
created

BackendGoogleFeedController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 62.86 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 3
dl 22
loc 35
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B actionSettings() 22 22 5

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\modules\shop\controllers;
4
5
6
use app\backend\components\BackendController;
7
use app\components\Helper;
8
use app\modules\shop\models\GoogleFeed;
9
use Yii;
10
11
class BackendGoogleFeedController extends BackendController
12
{
13
14
15
    public $defaultAction = 'settings';
16
17
    /**
18
     * @return string|\yii\web\Response
19
     * @throws \yii\web\ServerErrorHttpException
20
     */
21 View Code Duplication
    public function actionSettings()
22
    {
23
        if (\Yii::$app->request->isPost) {
24
            $model = new GoogleFeed();
25
            if ($model->load(Yii::$app->request->post()) && $model->validate()) {
26
                $model->saveConfig();
27
            } elseif ($model->hasErrors()) {
28
                Yii::$app->session->setFlash('error', Helper::formatModelErrors($model, '<br />'));
29
            }
30
            return $this->refresh();
31
        }
32
33
        $model = new GoogleFeed();
34
        $model->loadConfig();
35
36
        return $this->render(
37
            'settings',
38
            [
39
                'model' => $model
40
            ]
41
        );
42
    }
43
44
45
}