Completed
Push — master ( 5e5220...b96c8a )
by Chad
7s
created

Revoke::register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 4
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Chadicus\Slim\OAuth2\Routes;
4
5
use Chadicus\Slim\OAuth2\Http\MessageBridge;
6
use OAuth2;
7
use Slim\Slim;
8
9
/**
10
 * The revoke class.
11
 *
12
 */
13 View Code Duplication
class Revoke
0 ignored issues
show
Duplication introduced by
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...
14
{
15
    const ROUTE = '/revoke';
16
17
    /**
18
     * The slim framework application instance.
19
     *
20
     * @var Slim
21
     */
22
    private $slim;
23
24
    /**
25
     * The oauth2 server instance.
26
     *
27
     * @var OAuth2\Server
28
     */
29
    private $server;
30
31
    /**
32
     * Construct a new instance of Authorize.
33
     *
34
     * @param Slim          $slim   The slim framework application instance.
35
     * @param OAuth2\Server $server The oauth2 server imstance.
36
     */
37
    public function __construct(Slim $slim, OAuth2\Server $server)
38
    {
39
        $this->slim = $slim;
40
        $this->server = $server;
41
    }
42
43
    /**
44
     * Call this class as a function.
45
     *
46
     * @return void
47
     */
48
    public function __invoke()
49
    {
50
        $request = MessageBridge::newOAuth2Request($this->slim->request());
51
        MessageBridge::mapResponse(
52
            $this->server->handleRevokeRequest($request),
53
            $this->slim->response()
54
        );
55
    }
56
57
    /**
58
     * Register this route with the given Slim application and OAuth2 server
59
     *
60
     * @param Slim          $slim   The slim framework application instance.
61
     * @param OAuth2\Server $server The oauth2 server instance.
62
     *
63
     * @return void
64
     */
65
    public static function register(Slim $slim, OAuth2\Server $server)
66
    {
67
        $slim->post(self::ROUTE, new static($slim, $server))->name('revoke');
68
    }
69
}
70