Completed
Push — master ( 64cd9f...411f65 )
by Alexandre
02:13
created

AuthorizationCodeFlow   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getUnsupportedResponseModes() 0 3 1
A getDefaultResponseMode() 0 3 1
A getResponseTypes() 0 3 1
A __construct() 0 3 1
A handleAuthorizationRequest() 0 10 1
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\Storages\AuthorizationCodeStorageInterface;
14
15
class AuthorizationCodeFlow implements FlowInterface
16
{
17
    /**
18
     * @var AuthorizationCodeStorageInterface
19
     */
20
    private $authorizationCodeStorage;
21
22
    public function __construct(AuthorizationCodeStorageInterface $authorizationCodeStorage)
23
    {
24
        $this->authorizationCodeStorage = $authorizationCodeStorage;
25
    }
26
27
    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...
28
    {
29
        return ['code'];
30
    }
31
32
    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...
33
    {
34
        $authorizationCode = $this->authorizationCodeStorage->generate(
35
            implode(' ', $authorizationEndpoint->getScopes()),
36
            $authorizationEndpoint->getClient()->getIdentifier(),
37
            $authorizationEndpoint->getResourceOwner()->getIdentifier(),
38
            $requestData['scope'] ?? null,
39
            $requestData['redirect_uri'] ?? null
40
        );
41
        return ['code' => $authorizationCode->getCode()];
42
    }
43
44
    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...
45
    {
46
        return 'query';
47
    }
48
49
    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...
50
    {
51
        return [];
52
    }
53
}