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

Tokens::post()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 9
cp 0
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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