Passed
Branch master (9b4352)
by Rutger
13:03
created

Oauth2EncryptionController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 11
c 1
b 0
f 0
dl 0
loc 35
ccs 0
cts 8
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A actions() 0 5 1
A options() 0 8 2
A optionAliases() 0 4 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\encryption\Oauth2EncryptionKeyUsageAction;
7
use rhertogh\Yii2Oauth2Server\controllers\console\encryption\Oauth2RotateEncryptionKeysAction;
8
use yii\helpers\ArrayHelper;
9
10
class Oauth2EncryptionController extends Oauth2BaseConsoleController
11
{
12
    /**
13
     * @var string|null
14
     */
15
    public $keyName = null;
16
17
    /**
18
     * @inheritDoc
19
     */
20
    public function options($actionID)
21
    {
22
        if (in_array($actionID, ['key-usage', 'rotate-keys'])) {
23
            $options = [
24
                'keyName',
25
            ];
26
        }
27
        return ArrayHelper::merge(parent::options($actionID), $options ?? []);
28
    }
29
30
    public function optionAliases()
31
    {
32
        return ArrayHelper::merge(parent::optionAliases(), [
33
            'k' => 'keyName',
34
        ]);
35
    }
36
37
    /**
38
     * @inheritDoc
39
     */
40
    public function actions()
41
    {
42
        return [
43
            'key-usage' => Oauth2EncryptionKeyUsageAction::class,
44
            'rotate-keys' => Oauth2RotateEncryptionKeysAction::class,
45
        ];
46
    }
47
}
48