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

CreationChallenges   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A post() 9 9 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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