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.
Completed
Push — master ( 47ca6e...f43653 )
by Sam
07:20
created

MigrateController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 27.5 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 64.29%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 3
dl 11
loc 40
ccs 9
cts 14
cp 0.6429
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A stdout() 11 11 2
A beforeAction() 0 11 2
A actionUp() 0 7 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
declare(strict_types=1);
3
4
namespace SamIT\Yii2\PhpFpm\controllers;
5
6
7
use Docker\API\Model\BuildInfo;
8
use Docker\Context\Context;
9
use Docker\Context\ContextBuilder;
10
use Docker\Docker;
11
use Docker\Stream\BuildStream;
12
use SamIT\Yii2\PhpFpm\Module;
13
use yii\console\Controller;
14
use yii\console\ExitCode;
15
use yii\helpers\Console;
16
17
/**
18
 * Class MigrateController
19
 * @package SamIT\Yii2\PhpFpm\controllers
20
 * @property Module $module
21
 */
22
class MigrateController extends \yii\console\controllers\MigrateController
23
{
24 1
25 View Code Duplication
    public function stdout($string)
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...
26 1
    {
27
        if ($this->isColorEnabled()) {
28
            $args = \func_get_args();
29
            \array_shift($args);
30
            $string = Console::ansiFormat($string, $args);
31
        }
32 1
33 1
        echo $string;
34
        return \strlen($string);
35
    }
36 1
37
    public function beforeAction($action)
38
    {
39 1
        // Obtain lock.
40 1
        $this->stdout('Waiting for lock...', Console::FG_CYAN);
41
        if ($this->module->getLock()) {
42
            $this->stdout("OK\n", Console::FG_GREEN);
43 1
        } else {
44 1
            $this->stdout("FAIL\n", Console::FG_RED);
45
            return false;
46
        }
47
    }
48
49
    public function actionUp($limit = 0)
50
    {
51
        $command = "/project/{$this->module->getConsoleEntryScript()} migrate/up $limit";
52
        $result = ExitCode::OK;
53
        passthru($command, $result);
54
        return $result;
55
    }
56
57
58
59
60
61
}