Oauth2ClientController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 153
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 54
c 1
b 0
f 0
dl 0
loc 153
ccs 0
cts 37
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A actions() 0 9 1
A options() 0 32 3
1
<?php
2
3
namespace rhertogh\Yii2Oauth2Server\controllers\console;
4
5
use rhertogh\Yii2Oauth2Server\controllers\console\base\Oauth2BaseConsoleController;
6
use rhertogh\Yii2Oauth2Server\controllers\console\client\Oauth2UpdateClientAction;
7
use rhertogh\Yii2Oauth2Server\controllers\console\client\Oauth2ViewClientAction;
8
use rhertogh\Yii2Oauth2Server\interfaces\controllers\console\client\Oauth2CreateClientActionInterface;
9
use rhertogh\Yii2Oauth2Server\interfaces\controllers\console\client\Oauth2DeleteClientActionInterface;
10
use rhertogh\Yii2Oauth2Server\interfaces\controllers\console\client\Oauth2ListClientsActionInterface;
11
use rhertogh\Yii2Oauth2Server\interfaces\controllers\console\client\Oauth2SetClientSecretActionInterface;
12
use rhertogh\Yii2Oauth2Server\interfaces\controllers\console\Oauth2ClientControllerInterface;
13
use yii\helpers\ArrayHelper;
14
15
/**
16
 * Manage Oauth2 Clients.
17
 */
18
class Oauth2ClientController extends Oauth2BaseConsoleController implements Oauth2ClientControllerInterface
19
{
20
    /**
21
     * @inheritdoc
22
     */
23
    public $defaultAction = 'list';
24
25
    /**
26
     * @var string|null
27
     */
28
    public $sample = null;
29
30
    /**
31
     * @var string|null
32
     */
33
    public $identifier = null;
34
35
    /**
36
     * @var string|null
37
     */
38
    public $name = null;
39
40
    /**
41
     * @var string|null
42
     */
43
    public $type = null;
44
45
    /**
46
     * @var string|null
47
     */
48
    public $grantTypes = null;
49
50
    /**
51
     * @var string|null
52
     */
53
    public $redirectURIs = null;
54
55
    /**
56
     * @var string|null
57
     */
58
    public $allowVariableRedirectUriQuery = null;
59
60
    /**
61
     * @var string|null
62
     */
63
    public $secret = null;
64
65
    /**
66
     * @var string|null A PHP date/time string or, when starting with 'P', a PHP date interval string.
67
     * @see https://www.php.net/manual/en/datetime.formats.php
68
     * @see https://www.php.net/manual/en/dateinterval.construct.php
69
     */
70
    public $oldSecretValidUntil = null;
71
72
    /**
73
     * @var string|null
74
     */
75
    public $scopes = null;
76
77
    /**
78
     * @var string|null
79
     */
80
    public $allowGenericScopes = null;
81
82
    /**
83
     * @var string|null
84
     */
85
    public $exceptionOnInvalidScope = null;
86
87
    /**
88
     * @var string|null
89
     */
90
    public $endUsersMayAuthorizeClient = null;
91
92
    /**
93
     * @var string|null
94
     */
95
    public $userAccountSelection = null;
96
97
    /**
98
     * @var string|null
99
     */
100
    public $isAuthCodeWithoutPkceAllowed = null;
101
102
    /**
103
     * @var string|null
104
     */
105
    public $skipAuthorizationIfScopeIsAllowed = null;
106
107
    /**
108
     * @var string|null
109
     */
110
    public $logoUri = null;
111
112
    /**
113
     * @var string|null
114
     */
115
    public $termsOfServiceUri = null;
116
117
    /**
118
     * @var string|null
119
     */
120
    public $contacts = null;
121
122
    /**
123
     * @inheritDoc
124
     */
125
    public function options($actionID)
126
    {
127
        if ($actionID == 'create') {
128
            $options = [
129
                'sample',
130
                'identifier',
131
                'name',
132
                'type',
133
                'redirectURIs',
134
                'allowVariableRedirectUriQuery',
135
                'grantTypes',
136
                'secret',
137
                'scopes',
138
                'allowGenericScopes',
139
                'exceptionOnInvalidScope',
140
                'endUsersMayAuthorizeClient',
141
                'userAccountSelection',
142
                'isAuthCodeWithoutPkceAllowed',
143
                'skipAuthorizationIfScopeIsAllowed',
144
                'logoUri',
145
                'termsOfServiceUri',
146
                'contacts',
147
            ];
148
        } elseif ($actionID == 'set-secret') {
149
            $options = [
150
                'identifier',
151
                'secret',
152
                'oldSecretValidUntil',
153
            ];
154
        }
155
156
        return ArrayHelper::merge(parent::options($actionID), $options ?? []);
157
    }
158
159
    /**
160
     * @inheritDoc
161
     */
162
    public function actions()
163
    {
164
        return [
165
            'list' => Oauth2ListClientsActionInterface::class,
166
            'view' => Oauth2ViewClientAction::class,
167
            'create' => Oauth2CreateClientActionInterface::class,
168
            'update' => Oauth2UpdateClientAction::class,
169
            'set-secret' => Oauth2SetClientSecretActionInterface::class,
170
            'delete' => Oauth2DeleteClientActionInterface::class,
171
        ];
172
    }
173
}
174