Passed
Push — master ( fd01cd...a8d522 )
by Alexandre
02:26
created

AuthorizationCodeFlow::handleAccessTokenRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Alexandre
5
 * Date: 18/02/2018
6
 * Time: 18:08
7
 */
8
9
namespace OAuth2\Flows;
10
11
12
use OAuth2\Endpoints\AuthorizationEndpoint;
13
use OAuth2\Endpoints\TokenEndpoint;
14
use OAuth2\Storages\AuthorizationCodeStorageInterface;
15
16
class AuthorizationCodeFlow implements FlowInterface
17
{
18
    /**
19
     * @var AuthorizationCodeStorageInterface
20
     */
21
    protected $authorizationCodeStorage;
22
23
    public function __construct(AuthorizationCodeStorageInterface $authorizationCodeStorage)
24
    {
25
        $this->authorizationCodeStorage = $authorizationCodeStorage;
26
    }
27
28
    function getResponseTypes(): array
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
29
    {
30
        return ['code'];
31
    }
32
33
    function handleAuthorizationRequest(AuthorizationEndpoint $authorizationEndpoint, array $requestData): array
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
34
    {
35
        $authorizationCode = $this->authorizationCodeStorage->create(
36
            implode(' ', $authorizationEndpoint->getScopes()),
37
            $authorizationEndpoint->getClient()->getIdentifier(),
38
            $authorizationEndpoint->getResourceOwner()->getIdentifier(),
39
            $requestData['scope'] ?? null,
40
            $requestData['redirect_uri'] ?? null
41
        );
42
        $this->authorizationCodeStorage->save($authorizationCode);
43
        return ['code' => $authorizationCode->getCode()];
44
    }
45
46
    function getDefaultResponseMode(): string
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
47
    {
48
        return 'query';
49
    }
50
51
    function getUnsupportedResponseModes(): array
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
52
    {
53
        return [];
54
    }
55
56
    function getGrantTypes(): array
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
57
    {
58
        // TODO
59
        return [];
60
    }
61
62
    function handleAccessTokenRequest(TokenEndpoint $tokenEndpoint, array $requestData): array
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
63
    {
64
        // TODO
65
        return [];
66
    }
67
}