AuthorizationServerMiddleware   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 16
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A __invoke() 0 10 2
1
<?php
2
3
/**
4
 * @author      Alex Bilbie <[email protected]>
5
 * @copyright   Copyright (c) Alex Bilbie
6
 * @license     http://mit-license.org/
7
 *
8
 * @link        https://github.com/thephpleague/oauth2-server
9
 */
10
11
declare(strict_types=1);
12
13
namespace League\OAuth2\Server\Middleware;
14
15
use League\OAuth2\Server\AuthorizationServer;
16
use League\OAuth2\Server\Exception\OAuthServerException;
17
use Psr\Http\Message\ResponseInterface;
18
use Psr\Http\Message\ServerRequestInterface;
19
20
class AuthorizationServerMiddleware
21
{
22 2
    public function __construct(private AuthorizationServer $server)
23
    {
24 2
    }
25
26 2
    public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next): ResponseInterface
27
    {
28
        try {
29 2
            $response = $this->server->respondToAccessTokenRequest($request, $response);
30 1
        } catch (OAuthServerException $exception) {
31 1
            return $exception->generateHttpResponse($response);
32
        }
33
34
        // Pass the request and response on to the next responder in the chain
35 1
        return $next($request, $response);
36
    }
37
}
38