Test Failed
Push — master ( 817d84...d52e3d )
by Raffael
05:44
created

Tokens   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 31
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A post() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * balloon
7
 *
8
 * @copyright   Copryright (c) 2012-2019 gyselroth GmbH (https://gyselroth.com)
9
 * @license     GPL-3.0 https://opensource.org/licenses/GPL-3.0
10
 */
11
12
namespace Balloon\App\Idp\Api\v2;
13
14
use Balloon\Server;
15
use Micro\Http\Response;
16
use OAuth2\Request;
17
use OAuth2\Server as OAuth2Server;
18
19
class Tokens
20
{
21
    /**
22
     * Server.
23
     *
24
     * @var OAuth2Server
25
     */
26
    protected $server;
27
28
    /**
29
     * Initialize.
30
     */
31
    public function __construct(OAuth2Server $server)
32
    {
33
        $this->server = $server;
34
    }
35
36
    /**
37
     * Token endpoint.
38
     */
39
    public function post(): Response
40
    {
41
        $request = Request::createFromGlobals();
42
        $response = $this->server->handleTokenRequest($request);
43
        $params = $response->getParameters();
44
45
        return (new Response())
46
             ->setCode($response->getStatusCode())
47
             ->setBody($params);
48
    }
49
}
50