Failed Conditions
Pull Request — master (#17)
by
unknown
03:19
created

Revoke::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 8
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
0 ignored issues
show
Coding Style introduced by
End of line character is invalid; expected "\n" but found "\r\n"
Loading history...
2
3
namespace Chadicus\Slim\OAuth2\Routes;
4
5
use Chadicus\Slim\OAuth2\Http\MessageBridge;
6
use OAuth2;
7
use Slim\Slim;
8
9 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...
introduced by
Missing class doc comment
Loading history...
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.
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter name; 5 found
Loading history...
31
     * @param OAuth2\Server $server   The oauth2 server imstance.
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 3 found
Loading history...
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.
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter name; 5 found
Loading history...
57
     * @param OAuth2\Server $server   The oauth2 server instance.
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 3 found
Loading history...
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