HttpSecurityScheme::hasBearerFormat()   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\SecurityScheme;
6
7
use Aweapi\Openapi\Extensions;
8
use Aweapi\Openapi\Objects\SecurityScheme;
9
10
final class HttpSecurityScheme extends SecurityScheme
11
{
12
    private $bearerFormat;
13
14
    private $scheme;
15
16 2
    public function __construct(
17
        string $scheme,
18
        string $bearerFormat = null,
19
        string $description = null,
20
        Extensions $extensions = null
21
    ) {
22 2
        parent::__construct(
23 2
            SecurityScheme::TYPE_HTTP,
24
            $description,
25
            $extensions
26
        );
27 2
        $this->scheme = $scheme;
28 2
        $this->bearerFormat = $bearerFormat;
29
    }
30
31 1
    public function getBearerFormat(): string
32
    {
33 1
        return $this->bearerFormat;
34
    }
35
36 2
    public function getScheme(): string
37
    {
38 2
        return $this->scheme;
39
    }
40
41 2
    public function hasBearerFormat(): bool
42
    {
43 2
        return isset($this->bearerFormat);
44
    }
45
46 2
    protected function normalizeOptionalSchemeProperties(): array
47
    {
48
        return [
49 2
            'bearerFormat' => $this->hasBearerFormat() ? $this->getBearerFormat() : null,
50
        ];
51
    }
52
53 2
    protected function normalizeRequiredSchemeProperties(): array
54
    {
55
        return [
56 2
            'scheme' => $this->getScheme(),
57
        ];
58
    }
59
}
60