Passed
Push — master ( c9334a...8a0881 )
by Rutger
13:35
created

Oauth2PersonalAccessTokenGrantFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 8
c 1
b 0
f 0
dl 0
loc 27
ccs 7
cts 7
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getGrantType() 0 15 1
1
<?php
2
3
namespace rhertogh\Yii2Oauth2Server\components\factories\grants;
4
5
use rhertogh\Yii2Oauth2Server\interfaces\components\factories\grants\Oauth2PersonalAccessTokenGrantFactoryInterface;
6
use rhertogh\Yii2Oauth2Server\interfaces\components\server\grants\Oauth2PersonalAccessTokenGrantInterface;
7
use Yii;
8
9
class Oauth2PersonalAccessTokenGrantFactory extends base\Oauth2BaseGrantTypeFactory implements Oauth2PersonalAccessTokenGrantFactoryInterface
10
{
11
    /**
12
     * Time To Live for the access token, default value: 1 year.
13
     * The format should be a DateInterval duration (https://www.php.net/manual/en/dateinterval.construct.php).
14
     * @var string
15
     */
16
    public $accessTokenTTL = 'P1Y';
17
18
    /**
19
     * @inheritDoc
20
     */
21 3
    public function getGrantType()
22
    {
23
        /** @var Oauth2PersonalAccessTokenGrantInterface $patGrant */
24 3
        $patGrant = Yii::createObject(
25
            [
26 3
                'class' => Oauth2PersonalAccessTokenGrantInterface::class,
27 3
                'module' => $this->module,
28
            ],
29
            [
30 3
                $this->module->getUserRepository(),
31 3
                $this->module->getAccessTokenRepository(),
32
            ]
33
        );
34
35 3
        return $patGrant;
36
    }
37
}
38