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

Oauth2UserPatTrait::generatePersonalAccessToken()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 16
rs 9.9332
cc 3
nc 4
nop 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