Completed
Push — master ( 359a78...3fd1a2 )
by Chad
11s
created

src/Revoke.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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 View Code Duplication
final class Revoke implements RouteCallbackInterface
0 ignored issues
show
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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