KeysController::index()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 9
c 1
b 0
f 1
dl 0
loc 14
rs 9.9666
ccs 10
cts 10
cp 1
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
namespace ByTIC\Hello\Modules\Oauth\Controllers;
4
5
use League\OAuth2\Server\CryptKey;
6
use Nip\Container\Container;
7
use Nip\Controllers\Controller;
8
use Nip\Http\Response\JsonResponse;
9
10
/**
11
 * Class KeysController
12
 * @package ByTIC\Hello\Modules\Oauth\Controllers
13
 */
14
class KeysController extends Controller
15
{
16
    /**
17
     * @return JsonResponse
18
     */
19 1
    public function index()
20
    {
21 1
        $container = function_exists('app') ? app() : Container::getInstance();
22
        /** @var CryptKey $publicKey */
23 1
        $publicKey = $container->get('hello.keys.public');
24
25 1
        $key = new \stdClass();
26 1
        $key->alg = "RS256";
27 1
        $key->kty = "RSA";
28 1
        $key->use = "sig";
29 1
        $key->x5c = [file_get_contents($publicKey->getKeyPath())];
30 1
        $data = ['keys' => [$key]];
31
32 1
        return new JsonResponse($data);
33
    }
34
}
35