Revoke::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
1
<?php
2
3
namespace Chadicus\Slim\OAuth2\Routes;
4
5
use Chadicus\Slim\OAuth2\Http\RequestBridge;
6
use Chadicus\Slim\OAuth2\Http\ResponseBridge;
7
use Psr\Http\Message\ServerRequestInterface;
8
use Psr\Http\message\ResponseInterface;
9
use OAuth2;
10
11
/**
12
 * The revoke class.
13
 */
14
final class Revoke implements RouteCallbackInterface
15
{
16
    const ROUTE = '/revoke';
17
18
    /**
19
     * The oauth2 server instance.
20
     *
21
     * @var OAuth2\Server
22
     */
23
    private $server;
24
25
    /**
26
     * Construct a new instance of Authorize.
27
     *
28
     * @param OAuth2\Server $server The oauth2 server imstance.
29
     */
30
    public function __construct(OAuth2\Server $server)
31
    {
32
        $this->server = $server;
33
    }
34
35
    /**
36
     * Invoke this route callback.
37
     *
38
     * @param ServerRequestInterface $request   Represents the current HTTP request.
39
     * @param ResponseInterface      $response  Represents the current HTTP response.
40
     * @param array                  $arguments Values for the current route’s named placeholders.
41
     *
42
     * @return ResponseInterface
43
     */
44
    public function __invoke(ServerRequestInterface $request, ResponseInterface $response, array $arguments = [])
45
    {
46
        return ResponseBridge::fromOAuth2(
47
            $this->server->handleRevokeRequest(
48
                RequestBridge::toOAuth2($request)
49
            )
50
        );
51
    }
52
}
53