Passed
Pull Request — master (#6)
by
unknown
14:51
created

Oauth2UserPatTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 11
c 1
b 0
f 0
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A generatePersonalAccessToken() 0 16 3
1
<?php
2
3
namespace rhertogh\Yii2Oauth2Server\traits\models;
4
5
use rhertogh\Yii2Oauth2Server\interfaces\models\external\user\Oauth2UserInterface;
6
use rhertogh\Yii2Oauth2Server\Oauth2Module;
7
use Yii;
8
use yii\web\IdentityInterface;
9
10
trait Oauth2UserPatTrait
11
{
0 ignored issues
show
Coding Style introduced by
Opening brace must not be followed by a blank line
Loading history...
12
13
    public function generatePersonalAccessToken($clientIdentifier, $scope = null, $clientSecret = true)
14
    {
15
        if (property_exists(static::class, 'oauth2ModuleName')) {
16
            $oauth2ModuleName = static::$oauth2ModuleName;
17
        }
18
19
        /** @var Oauth2Module $module */
20
        $module = empty($oauth2ModuleName)
21
            ? Oauth2Module::getInstance()
22
            : Yii::$app->getModule($oauth2ModuleName);
23
24
        $result = $module->generatePersonalAccessToken(
0 ignored issues
show
Unused Code introduced by
The assignment to $result is dead and can be removed.
Loading history...
25
            $clientIdentifier,
26
            $this->id,
27
            $scope,
28
            $clientSecret
29
        );
30
    }
31
}
32