Completed
Push — master ( b97427...e235cc )
by Raffael
30:35 queued 26:08
created

CreationChallenges::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 5
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 5
loc 5
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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\Webauthn\Api\v2;
13
14
use Balloon\App\Webauthn\CreationChallenge\CreationChallengeFactory;
15
use Balloon\Server;
16
use Micro\Http\Response;
17
18 View Code Duplication
class CreationChallenges
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
{
20
    /**
21
     * CreationChallengeFactory.
22
     *
23
     * @var CreationChallengeFactory
24
     */
25
    protected $creation_challenge_factory;
26
27
    /**
28
     * Server.
29
     *
30
     * @var Server
31
     */
32
    protected $server;
33
34
    /**
35
     * Initialize.
36
     */
37
    public function __construct(CreationChallengeFactory $creation_challenge_factory, Server $server)
38
    {
39
        $this->creation_challenge_factory = $creation_challenge_factory;
40
        $this->server = $server;
41
    }
42
43
    /**
44
     * Challenge endpoint.
45
     */
46
    public function post(string $domain): Response
47
    {
48
        $resource = $this->creation_challenge_factory->create($this->server->getIdentity(), $domain);
49
50
        return (new Response())->setCode(201)->setBody([
51
            'id' => (string) $resource['id'],
52
            'key' => $resource['key'],
53
        ]);
54
    }
55
}
56