Passed
Push — master ( 63d167...fb60c6 )
by Rutger
03:11
created

Oauth2MigrationsController::options()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2.0116

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 11
ccs 6
cts 7
cp 0.8571
rs 10
cc 2
nc 2
nop 1
crap 2.0116
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 rhertogh\Yii2Oauth2Server\interfaces\controllers\console\Oauth2MigrationsControllerInterface;
9
use yii\helpers\ArrayHelper;
10
11
class Oauth2MigrationsController extends Oauth2BaseConsoleController implements Oauth2MigrationsControllerInterface
12
{
13
    /**
14
     * Name of the database component.
15
     * @var string
16
     */
17
    public $db = 'db';
18
19
    /**
20
     * Force generation of existing migrations.
21
     * @var bool
22
     */
23
    public $force = false;
24
25
    /**
26
     * @inheritDoc
27
     */
28 1
    public function options($actionID)
29
    {
30 1
        $options = ArrayHelper::merge(parent::options($actionID), [
31 1
            'force',
32 1
        ]);
33
34 1
        if ($actionID === 'generate-import') {
35
            $options[] = 'db';
36
        }
37
38 1
        return $options;
39
    }
40
41
    /**
42
     * @inheritDoc
43
     */
44 1
    public function optionAliases()
45
    {
46 1
        return ArrayHelper::merge(parent::optionAliases(), [
47 1
            'f' => 'force',
48 1
        ]);
49
    }
50
51
    /**
52
     * @inheritDoc
53
     */
54 1
    public function actions()
55
    {
56 1
        return [
57 1
            'generate' => Oauth2GenerateMigrationsAction::class,
58 1
            'generate-import' => Oauth2GenerateImportMigrationAction::class,
59 1
        ];
60
    }
61
}
62