Response::hasHeaders()   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
final class Response extends ValueObject implements ResponseAggregate
11
{
12
    use Properties\Description;
13
    use Properties\OptionalMediaTypeContent;
14
    use Properties\OptionalExtensions;
15
16
    private $headers;
17
18
    private $links;
19
20 16
    public function __construct(
21
        string $description,
22
        Headers $headers = null,
23
        MediaTypes $content = null,
24
        Links $links = null,
25
        Extensions $extensions = null
26
    ) {
27 16
        $this->description = $description;
28 16
        $this->headers = $headers;
29 16
        $this->content = $content;
30 16
        $this->links = $links;
31 16
        $this->extensions = $extensions;
32
    }
33
34 2
    public function getHeaders(): Headers
35
    {
36 2
        return $this->headers;
37
    }
38
39 2
    public function getLinks(): Links
40
    {
41 2
        return $this->links;
42
    }
43
44 15
    public function hasHeaders(): bool
45
    {
46 15
        return isset($this->headers);
47
    }
48
49 15
    public function hasLinks(): bool
50
    {
51 15
        return isset($this->links);
52
    }
53
54 15
    public function jsonSerialize(): ?array
55
    {
56 15
        return $this->extendedProperties(parent::jsonSerialize());
57
    }
58
59 15
    protected function normalizeOptionalProperties(): array
60
    {
61
        return [
62 15
            'headers' => $this->hasHeaders() ? $this->getHeaders()->jsonSerialize() : null,
63 15
            'content' => $this->getNormalizedContent(),
64 15
            'links' => $this->hasLinks() ? $this->getLinks()->jsonSerialize() : null,
65
        ];
66
    }
67
68 15
    protected function normalizeRequiredProperties(): array
69
    {
70
        return [
71 15
            'description' => $this->getDescription(),
72
        ];
73
    }
74
}
75