SecurityScheme   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 56
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A getType() 0 4 1
A jsonSerialize() 0 4 1
A normalizeOptionalProperties() 0 6 1
A normalizeOptionalSchemeProperties() 0 4 1
A normalizeRequiredProperties() 0 6 1
normalizeRequiredSchemeProperties() 0 1 ?
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Aweapi\Openapi\Objects;
6
7
use Aweapi\Openapi\Extensions;
8
use Aweapi\Openapi\ValueObject;
9
10
abstract class SecurityScheme extends ValueObject implements SecuritySchemeAggregate
11
{
12
    use Properties\OptionalDescription;
13
    use Properties\OptionalExtensions;
14
15
    public const TYPE_API_KEY = 'apiKey';
16
17
    public const TYPE_HTTP = 'http';
18
19
    public const TYPE_OAUTH2 = 'oauth2';
20
21
    public const TYPE_OPEN_ID_CONNECT = 'openIdConnect';
22
23
    private $type;
24
25 10
    public function __construct(
26
        string $type,
27
        string $description = null,
28
        Extensions $extensions = null
29
    ) {
30 10
        $this->type = $type;
31 10
        $this->description = $description;
32 10
        $this->extensions = $extensions;
33
    }
34
35 9
    public function getType(): string
36
    {
37 9
        return $this->type;
38
    }
39
40 9
    final public function jsonSerialize(): ?array
41
    {
42 9
        return $this->extendedProperties(parent::jsonSerialize());
43
    }
44
45 9
    protected function normalizeOptionalProperties(): array
46
    {
47
        return [
48 9
            'description' => $this->getNormalizedDescription(),
49 9
        ] + $this->normalizeOptionalSchemeProperties();
50
    }
51
52 7
    protected function normalizeOptionalSchemeProperties(): array
53
    {
54 7
        return [];
55
    }
56
57 9
    protected function normalizeRequiredProperties(): array
58
    {
59
        return [
60 9
            'type' => $this->getType(),
61 9
        ] + $this->normalizeRequiredSchemeProperties();
62
    }
63
64
    abstract protected function normalizeRequiredSchemeProperties(): array;
65
}
66