Test Failed
Pull Request — master (#350)
by Raffael
26:39
created

RequestChallenges::post()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 9
loc 9
ccs 0
cts 8
cp 0
rs 9.9666
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\RequestChallenge\RequestChallengeFactory;
15
use Balloon\Server;
16
use Micro\Http\Response;
17
use MongoDB\BSON\ObjectId;
18
19 View Code Duplication
class RequestChallenges
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...
20
{
21
    /**
22
     * RequestChallengeFactory.
23
     *
24
     * @var RequestChallengeFactory
25
     */
26
    protected $request_challenge_factory;
27
28
    /**
29
     * Server.
30
     *
31
     * @var Server
32
     */
33
    protected $server;
34
35
    /**
36
     * Initialize.
37
     */
38
    public function __construct(RequestChallengeFactory $request_challenge_factory, Server $server)
39
    {
40
        $this->request_challenge_factory = $request_challenge_factory;
41
        $this->server = $server;
42
    }
43
44
    /**
45
     * Challenge endpoint.
46
     */
47
    public function post(ObjectId $id, string $domain): Response
48
    {
49
        $resource = $this->request_challenge_factory->create($id, $domain);
50
51
        return (new Response())->setCode(201)->setBody([
52
            'id' => (string) $resource['id'],
53
            'key' => $resource['key'],
54
        ]);
55
    }
56
}
57