Completed
Push — master ( 8696cf...c1ad79 )
by Julien
03:04
created

OAuth2JsonControllerProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A connect() 0 16 2
1
<?php
2
3
namespace Eole\Sandstone\OAuth2\Silex;
4
5
use Symfony\Component\HttpFoundation\Request;
6
use Symfony\Component\HttpFoundation\JsonResponse;
7
use Symfony\Component\HttpKernel\Exception\HttpException;
8
use Silex\Api\ControllerProviderInterface;
9
use Silex\Application;
10
11
class OAuth2JsonControllerProvider implements ControllerProviderInterface
12
{
13
    /**
14
     * {@inheritDoc}
15
     */
16
    public function connect(Application $app)
17
    {
18
        $controllers = $app['controllers_factory'];
19
20
        $controllers->post('/access-token', function (Request $request) use ($app) {
21
            try {
22
                $token = $app['sandstone.oauth.controller']->postAccessToken($request);
23
24
                return new JsonResponse($token);
25
            } catch (OAuthException $e) {
0 ignored issues
show
Bug introduced by
The class Eole\Sandstone\OAuth2\Silex\OAuthException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
26
                throw new HttpException($e->httpStatusCode, $e->errorType.': '.$e->getMessage(), $e);
27
            }
28
        });
29
30
        return $controllers;
31
    }
32
}
33