Passed
Push — master ( 207765...57309d )
by Rutger
03:12
created

Oauth2MigrationsController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 93.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 13
c 1
b 0
f 0
dl 0
loc 48
ccs 14
cts 15
cp 0.9333
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A options() 0 11 2
A optionAliases() 0 4 1
A actions() 0 5 1
1
<?php
2
3
namespace rhertogh\Yii2Oauth2Server\controllers\console;
4
5
use rhertogh\Yii2Oauth2Server\controllers\console\base\Oauth2BaseConsoleController;
6
use rhertogh\Yii2Oauth2Server\controllers\console\migrations\Oauth2GenerateImportMigrationAction;
7
use rhertogh\Yii2Oauth2Server\controllers\console\migrations\Oauth2GenerateMigrationsAction;
8
use yii\helpers\ArrayHelper;
9
10
class Oauth2MigrationsController extends Oauth2BaseConsoleController
11
{
12
    /**
13
     * Name of the database component.
14
     * @var string
15
     */
16
    public $db = 'db';
17
18
    /**
19
     * Force generation of existing migrations.
20
     * @var bool
21
     */
22
    public $force = false;
23
24
    /**
25
     * @inheritDoc
26
     */
27 1
    public function options($actionID)
28
    {
29 1
        $options = ArrayHelper::merge(parent::options($actionID), [
30 1
            'force',
31 1
        ]);
32
33 1
        if ($actionID === 'generate-import') {
34
            $options[] = 'db';
35
        }
36
37 1
        return $options;
38
    }
39
40
    /**
41
     * @inheritDoc
42
     */
43 1
    public function optionAliases()
44
    {
45 1
        return ArrayHelper::merge(parent::optionAliases(), [
46 1
            'f' => 'force',
47 1
        ]);
48
    }
49
50
    /**
51
     * @inheritDoc
52
     */
53 1
    public function actions()
54
    {
55 1
        return [
56 1
            'generate' => Oauth2GenerateMigrationsAction::class,
57 1
            'generate-import' => Oauth2GenerateImportMigrationAction::class,
58 1
        ];
59
    }
60
}
61