Code Duplication    Length = 57-57 lines in 2 locations

src/Revoke.php 1 location

@@ 9-65 (lines=57) @@
6
use OAuth2;
7
use Slim\Slim;
8
9
class Revoke
10
{
11
    const ROUTE = '/revoke';
12
13
    /**
14
     * The slim framework application instance.
15
     *
16
     * @var Slim
17
     */
18
    private $slim;
19
20
    /**
21
     * The oauth2 server instance.
22
     *
23
     * @var OAuth2\Server
24
     */
25
    private $server;
26
27
    /**
28
     * Construct a new instance of Authorize.
29
     *
30
     * @param Slim          $slim     The slim framework application instance.
31
     * @param OAuth2\Server $server   The oauth2 server imstance.
32
     */
33
    public function __construct(Slim $slim, OAuth2\Server $server)
34
    {
35
        $this->slim = $slim;
36
        $this->server = $server;
37
    }
38
39
    /**
40
     * Call this class as a function.
41
     *
42
     * @return void
43
     */
44
    public function __invoke()
45
    {
46
        $request = MessageBridge::newOAuth2Request($this->slim->request());
47
        MessageBridge::mapResponse(
48
            $this->server->handleRevokeRequest($request),
49
            $this->slim->response()
50
        );
51
    }
52
53
    /**
54
     * Register this route with the given Slim application and OAuth2 server
55
     *
56
     * @param Slim          $slim     The slim framework application instance.
57
     * @param OAuth2\Server $server   The oauth2 server instance.
58
     *
59
     * @return void
60
     */
61
    public static function register(Slim $slim, OAuth2\Server $server)
62
    {
63
        $slim->post(self::ROUTE, new static($slim, $server))->name('revoke');
64
    }
65
}
66

src/Token.php 1 location

@@ 12-68 (lines=57) @@
9
/**
10
 * Slim route for /token endpoint.
11
 */
12
class Token
13
{
14
    const ROUTE = '/token';
15
16
    /**
17
     * The slim framework application.
18
     *
19
     * @var Slim
20
     */
21
    private $slim;
22
23
    /**
24
     * The OAuth2 server instance.
25
     *
26
     * @var OAuth2\Server
27
     */
28
    private $server;
29
30
    /**
31
     * Create a new instance of the Token route.
32
     *
33
     * @param Slim          $slim   The slim framework application instance.
34
     * @param OAuth2\Server $server The oauth2 server imstance.
35
     */
36
    public function __construct(Slim $slim, OAuth2\Server $server)
37
    {
38
        $this->slim = $slim;
39
        $this->server = $server;
40
    }
41
42
    /**
43
     * Allows this class to be callable.
44
     *
45
     * @return void
46
     */
47
    public function __invoke()
48
    {
49
        $request = MessageBridge::newOAuth2Request($this->slim->request());
50
        MessageBridge::mapResponse(
51
            $this->server->handleTokenRequest($request),
52
            $this->slim->response()
53
        );
54
    }
55
56
    /**
57
     * Register this route with the given Slim application and OAuth2 server
58
     *
59
     * @param Slim          $slim   The slim framework application instance.
60
     * @param OAuth2\Server $server The oauth2 server imstance.
61
     *
62
     * @return void
63
     */
64
    public static function register(Slim $slim, OAuth2\Server $server)
65
    {
66
        $slim->post(self::ROUTE, new static($slim, $server))->name('token');
67
    }
68
}
69