Passed
Push — master ( 36be2d...32b990 )
by Carlos
02:58
created

SiteController::actions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace app\controllers;
4
5
use roaresearch\yii2\oauth2server\filters\{
6
    auth\CompositeAuth,
7
    RevokeAccessToken
8
};
9
use yii\rest\Controller;
10
11
class SiteController extends Controller
12
{
13
    public function behaviors()
14
    {
15
        return array_merge(parent::behaviors(), [
16
            'authenticator' => [
17
                'class' => CompositeAuth::class,
18
                'actionScopes' => ['user' => 'user'],
19
            ],
20
            'tokenRevoke' => [
21
                'class' => RevokeAccessToken::class,
22
                'only' => ['single-use'],
23
            ],
24
        ]);
25
    }
26
27
    public function actions()
28
    {
29
        return [
30
            'error' => [
31
                'class' => 'yii\web\ErrorAction',
32
            ],
33
        ];
34
    }
35
36
    public function actionIndex(): object
37
    {
38
        return \Yii::$app->user->identity;
0 ignored issues
show
Bug Best Practice introduced by
The expression return Yii::app->user->identity could return the type null which is incompatible with the type-hinted return object. Consider adding an additional type-check to rule them out.
Loading history...
39
    }
40
41
    public function actionUser(): object
42
    {
43
        return \Yii::$app->user->identity;
0 ignored issues
show
Bug Best Practice introduced by
The expression return Yii::app->user->identity could return the type null which is incompatible with the type-hinted return object. Consider adding an additional type-check to rule them out.
Loading history...
44
    }
45
46
    public function actionSingleUse(): object
47
    {
48
        return \Yii::$app->user->identity;
0 ignored issues
show
Bug Best Practice introduced by
The expression return Yii::app->user->identity could return the type null which is incompatible with the type-hinted return object. Consider adding an additional type-check to rule them out.
Loading history...
49
    }
50
}
51