Oauth2UserPatTrait::generatePersonalAccessToken()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

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