Completed
Push — master ( 935a4f...80b369 )
by Veaceslav
01:53
created

Encoding::getHeaders()   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 Encoding extends ValueObject
11
{
12
    use Properties\OptionalExtensions;
13
14
    private $allowReserved;
15
16
    private $contentType;
17
18
    private $explode;
19
20
    private $headers;
21
22
    private $style;
23
24 5
    public function __construct(
25
        string $contentType = null,
26
        Headers $headers = null,
27
        string $style = null,
28
        bool $explode = true,
29
        bool $allowReserved = false,
30
        Extensions $extensions = null
31
    ) {
32 5
        $this->contentType = $contentType;
33 5
        $this->headers = $headers;
34 5
        $this->style = $style;
35 5
        $this->explode = $explode;
36 5
        $this->allowReserved = $allowReserved;
37 5
        $this->extensions = $extensions;
38
    }
39
40 3
    public function getContentType(): string
41
    {
42 3
        return $this->contentType;
43
    }
44
45 1
    public function getHeaders(): Headers
46
    {
47 1
        return $this->headers;
48
    }
49
50 1
    public function getStyle(): string
51
    {
52 1
        return $this->style;
53
    }
54
55 4
    public function hasContentType(): bool
56
    {
57 4
        return isset($this->contentType);
58
    }
59
60 4
    public function hasHeaders(): bool
61
    {
62 4
        return isset($this->headers);
63
    }
64
65 4
    public function hasStyle(): bool
66
    {
67 4
        return isset($this->style);
68
    }
69
70 4
    public function isAllowReserved(): bool
71
    {
72 4
        return $this->allowReserved;
73
    }
74
75 4
    public function isExplode(): bool
76
    {
77 4
        return $this->explode;
78
    }
79
80 4
    public function jsonSerialize(): ?array
81
    {
82 4
        return $this->extendedProperties(parent::jsonSerialize());
83
    }
84
85 4
    protected function normalizeOptionalProperties(): array
86
    {
87
        return [
88 4
            'contentType' => $this->hasContentType() ? $this->getContentType() : null,
89 4
            'headers' => $this->hasHeaders() ? $this->getHeaders()->jsonSerialize() : null,
90 4
            'style' => $this->hasStyle() ? $this->getStyle() : null,
91 4
            'explode' => $this->isExplode() ? null : false,
92 4
            'allowReserved' => $this->isAllowReserved() ?: null,
93
        ];
94
    }
95
}
96