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

SiteController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 38
rs 10
c 1
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A actions() 0 5 1
A behaviors() 0 10 1
A actionIndex() 0 3 1
A actionUser() 0 3 1
A actionSingleUse() 0 3 1
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