chadicus /
slim-oauth2-routes
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
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
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...
|
|||
| 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
|
|||
| 31 | * @param OAuth2\Server $server The oauth2 server imstance. |
||
|
0 ignored issues
–
show
|
|||
| 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
|
|||
| 57 | * @param OAuth2\Server $server The oauth2 server instance. |
||
|
0 ignored issues
–
show
|
|||
| 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 |