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 — filters ( b41112...24729b )
by
unknown
13:18
created

BackendGoogleFeedController   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 55
Duplicated Lines 69.09 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
lcom 1
cbo 4
dl 38
loc 55
rs 10
c 2
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B actionSettings() 20 20 6
A actionCreate() 18 18 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\modules\shop\controllers;
4
5
6
use app\backend\components\BackendController;
7
use app\backgroundtasks\helpers\BackgroundTasks;
8
use app\components\Helper;
9
use app\modules\shop\models\GoogleFeed;
10
use Yii;
11
12
class BackendGoogleFeedController extends BackendController
13
{
14
15
16
    public $defaultAction = 'settings';
17
18
    /**
19
     * @return string|\yii\web\Response
20
     * @throws \yii\web\ServerErrorHttpException
21
     */
22 View Code Duplication
    public function actionSettings()
23
    {
24
        if (\Yii::$app->request->isPost) {
25
            $model = new GoogleFeed();
26
            if (Yii::$app->request->isPost && $model->load(Yii::$app->request->post()) && $model->validate()) {
27
                $model->saveConfig();
28
            } elseif ($model->hasErrors()) {
29
                Yii::$app->session->setFlash('error', Helper::formatModelErrors($model, '<br />'));
30
            }
31
            return $this->refresh();
32
        }
33
        $model = new GoogleFeed();
34
        $model->loadConfig();
35
        return $this->render(
36
            'settings',
37
            [
38
                'model' => $model
39
            ]
40
        );
41
    }
42
43
    /**
44
     * @return \yii\web\Response
45
     */
46 View Code Duplication
    public function actionCreate()
47
    {
48
        BackgroundTasks::addTask(
49
            [
50
                'name' => 'google_merchants_generate',
51
                'description' => 'Creating YML file',
52
                'action' => 'shop/google-merchants/generate',
53
                'params' => '',
54
                'init_event' => 'shop/google_merchants',
55
            ],
56
            [
57
                'create_notification' => true,
58
            ]
59
        );
60
61
        Yii::$app->session->setFlash('success', 'Task has been created.');
62
        return $this->redirect(['settings']);
63
    }
64
65
66
}