SecurityScheme::getType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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