Passed
Pull Request — master (#6)
by Carlos
13:17
created

Server::verifyResourceRequest()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 1
nop 3
dl 0
loc 9
ccs 4
cts 4
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace roaresearch\yii2\oauth2server;
4
5
use OAuth2\{
6
    ClientAssertionType\ClientAssertionTypeInterface,
7
    RequestInterface,
8
    ResponseInterface,
9
    ScopeInterface,
10
    Server as BaseServer,
11
    TokenType\TokenTypeInterface
12
};
13
14
class Server extends BaseServer
15
{
16 9
    public function __construct(
17
        protected Module $module,
18
        $storage = [],
19
        array $config = [],
20
        array $grantTypes = [],
21
        array $responseTypes = [],
22
        TokenTypeInterface $tokenType = null,
23
        ScopeInterface $scopeUtil = null,
24
        ClientAssertionTypeInterface $clientAssertionType = null
25
    ) {
26 9
        parent::__construct(
27
            $storage,
28
            $config,
29
            $grantTypes,
30
            $responseTypes,
31
            $tokenType,
32
            $scopeUtil,
33
            $clientAssertionType
34
        );
35
    }
36
37
    public function createAccessToken(
38
        $clientId,
39
        $userId,
40
        $scope = null,
41
        $includeRefreshToken = true
42
    ) {
43
        return $this->getAccessTokenResponseType()->createAccessToken(
44
            $clientId,
45
            $userId,
46
            $scope,
47
            $includeRefreshToken
48
        );
49
    }
50
51
    /**
52
     * @inheritdoc
53
     */
54 4
    public function verifyResourceRequest(
55
        RequestInterface $request = null,
56
        ResponseInterface $response = null,
57
        $scope = null
58
    ) {
59 4
        parent::verifyResourceRequest(
60 4
            $request ?: $this->module->getRequest(),
61 4
            $response ?: $this->module->getResponse(),
62
            $scope
63
        );
64
    }
65
66
    /**
67
     * @inheritdoc
68
     */
69 5
    public function handleTokenRequest(
70
        RequestInterface $request = null,
71
        ResponseInterface $response = null
72
    ) {
73 5
        return parent::handleTokenRequest(
74 5
            $request ?: $this->module->getRequest(),
75 5
            $response ?: $this->module->getResponse()
76
        );
77
    }
78
}
79