Passed
Push — master ( cd0cec...4b3abd )
by Alexandre
06:20
created

ImplicitFlow::getDefaultResponseMode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Alexandre
5
 * Date: 14/03/2018
6
 * Time: 22:13
7
 */
8
9
namespace OAuth2\Extensions\OpenID\Flows;
10
11
12
use OAuth2\Endpoints\AuthorizationEndpoint;
13
use OAuth2\Endpoints\TokenEndpoint;
14
use OAuth2\Exceptions\OAuthException;
15
use OAuth2\Extensions\OpenID\IdTokenManager;
16
use OAuth2\Flows\FlowInterface;
17
use OAuth2\GrantTypes\AbstractGrantType;
18
use OAuth2\Storages\AccessTokenStorageInterface;
19
use OAuth2\Storages\RefreshTokenStorageInterface;
20
21
class ImplicitFlow extends AbstractGrantType implements FlowInterface
22
{
23
    /**
24
     * @var IdTokenManager
25
     */
26
    private $idTokenManager;
27
28
    public function __construct(IdTokenManager $idTokenManager,
29
                                AccessTokenStorageInterface $accessTokenStorage,
30
                                RefreshTokenStorageInterface $refreshTokenStorage)
31
    {
32
        parent::__construct($accessTokenStorage, $refreshTokenStorage);
33
        $this->idTokenManager = $idTokenManager;
34
    }
35
36
    /**
37
     * @return string[]
38
     */
39
    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...
40
    {
41
        return [
42
            'id_token',
43
            'id_token token'
44
        ];
45
    }
46
47
    /**
48
     * @return string[]
49
     */
50
    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...
51
    {
52
        return [];
53
    }
54
55
    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...
56
    {
57
        return [];
58
    }
59
60
    /**
61
     * @param AuthorizationEndpoint $authorizationEndpoint
62
     * @param array $requestData
63
     * @throws OAuthException
64
     */
65
    public function verifyAuthorizationRequest(AuthorizationEndpoint $authorizationEndpoint, array $requestData) {
66
        if(empty($requestData['nonce'])) {
67
            throw new OAuthException('invalid_request', 'Nonce required');
68
        }
69
    }
70
71
    public function handleAuthorizationRequest(AuthorizationEndpoint $authorizationEndpoint, array $requestData): array
72
    {
73
        // TODO
74
        $idToken = 'aze';
75
        return [
76
            'id_token' => $idToken
77
        ];
78
//        var_dump($requestData);
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
79
//        die;
80
    }
81
82
    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...
83
    {
84
        return 'fragment';
85
    }
86
87
    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...
88
    {
89
        return ['query'];
90
    }
91
}