Completed
Pull Request — master (#4)
by Veaceslav
02:34
created

ServerVariable::getEnum()   A

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
final class ServerVariable extends ValueObject
11
{
12
    use Properties\OptionalDescription;
13
    use Properties\OptionalExtensions;
14
15
    private $default;
16
17
    private $enum;
18
19 5
    public function __construct(
20
        bool $default,
21
        array $enum = null,
22
        string $description = null,
23
        Extensions $extensions = null
24
    ) {
25 5
        $this->default = $default;
26 5
        $this->enum = $enum;
27 5
        $this->description = $description;
28 5
        $this->extensions = $extensions;
29
    }
30
31 1
    public function getEnum(): array
32
    {
33 1
        return $this->enum;
34
    }
35
36 4
    public function hasEnum(): bool
37
    {
38 4
        return isset($this->enum);
39
    }
40
41 4
    public function isDefault(): bool
42
    {
43 4
        return $this->default;
44
    }
45
46 4
    public function jsonSerialize(): ?array
47
    {
48 4
        return $this->extendedProperties(parent::jsonSerialize());
49
    }
50
51 4
    protected function normalizeOptionalProperties(): array
52
    {
53
        return [
54 4
            'enum' => $this->hasEnum() ? $this->getEnum() : null,
55 4
            'description' => $this->getNormalizedDescription(),
56
        ];
57
    }
58
59 4
    protected function normalizeRequiredProperties(): array
60
    {
61
        return [
62 4
            'default' => $this->isDefault(),
63
        ];
64
    }
65
}
66