TokenRevocationGetEndpoint   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 22
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getRequestParameters() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2019 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\Component\TokenRevocationEndpoint;
15
16
use Psr\Http\Message\ResponseFactoryInterface;
17
use Psr\Http\Message\ServerRequestInterface;
18
use function Safe\array_flip;
19
20
final class TokenRevocationGetEndpoint extends TokenRevocationEndpoint
21
{
22
    /**
23
     * @var bool
24
     */
25
    private $allowJson;
26
27
    public function __construct(TokenTypeHintManager $tokenTypeHintManager, ResponseFactoryInterface $responseFactory, bool $allowJson)
28
    {
29
        parent::__construct($tokenTypeHintManager, $responseFactory);
30
        $this->allowJson = $allowJson;
31
    }
32
33
    protected function getRequestParameters(ServerRequestInterface $request): array
34
    {
35
        $parameters = $request->getQueryParams();
36
        $supported_parameters = ['token', 'token_type_hint'];
37
        if (true === $this->allowJson) {
38
            $supported_parameters[] = 'callback';
39
        }
40
41
        return array_intersect_key($parameters, array_flip($supported_parameters));
42
    }
43
}
44