Oauth2UserPatTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 11
c 1
b 0
f 0
dl 0
loc 18
ccs 0
cts 11
cp 0
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\Oauth2Module;
6
use Yii;
7
8
trait Oauth2UserPatTrait
9
{
10
    public function generatePersonalAccessToken($clientIdentifier, $scope = null, $clientSecret = true)
11
    {
12
        if (property_exists(static::class, 'oauth2ModuleName')) {
13
            $oauth2ModuleName = static::$oauth2ModuleName;
14
        }
15
16
        /** @var Oauth2Module $module */
17
        $module = empty($oauth2ModuleName)
18
            ? Oauth2Module::getInstance()
19
            : Yii::$app->getModule($oauth2ModuleName);
20
21
        return $module->generatePersonalAccessToken(
22
            $clientIdentifier,
23
            $this->id,
24
            $scope,
25
            $clientSecret
26
        );
27
    }
28
}
29