Components::normalizeOptionalProperties()   B
last analyzed

Complexity

Conditions 8
Paths 128

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 8

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 10
cts 10
cp 1
rs 8.2111
c 0
b 0
f 0
cc 8
nc 128
nop 0
crap 8
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 Components extends ValueObject
11
{
12
    use Properties\OptionalExamples;
13
    use Properties\OptionalCallbacks;
14
    use Properties\OptionalExtensions;
15
16
    private $headers;
17
18
    private $links;
19
20
    private $parameters;
21
22
    private $requestBodies;
23
24
    private $responses;
25
26
    private $schemas;
27
28
    private $securitySchemes;
29
30 6
    public function __construct(
31
        Schemas $schemas = null,
32
        Responses $responses = null,
33
        Parameters $parameters = null,
34
        RequestBodies $requestBodies = null,
35
        Headers $headers = null,
36
        SecuritySchemes $securitySchemes = null,
37
        Links $links = null,
38
        CallbackRequests $callbacks = null,
39
        Examples $examples = null,
40
        Extensions $extensions = null
41
    ) {
42 6
        $this->schemas = $schemas;
43 6
        $this->responses = $responses;
44 6
        $this->parameters = $parameters;
45 6
        $this->requestBodies = $requestBodies;
46 6
        $this->headers = $headers;
47 6
        $this->securitySchemes = $securitySchemes;
48 6
        $this->links = $links;
49 6
        $this->callbacks = $callbacks;
50 6
        $this->examples = $examples;
51 6
        $this->extensions = $extensions;
52
    }
53
54 2
    public function getHeaders(): Headers
55
    {
56 2
        return $this->headers;
57
    }
58
59 2
    public function getLinks(): Links
60
    {
61 2
        return $this->links;
62
    }
63
64 2
    public function getParameters(): Parameters
65
    {
66 2
        return $this->parameters;
67
    }
68
69 2
    public function getRequestBodies(): RequestBodies
70
    {
71 2
        return $this->requestBodies;
72
    }
73
74 2
    public function getResponses(): Responses
75
    {
76 2
        return $this->responses;
77
    }
78
79 4
    public function getSchemas(): Schemas
80
    {
81 4
        return $this->schemas;
82
    }
83
84 1
    public function getSecuritySchemes(): SecuritySchemes
85
    {
86 1
        return $this->securitySchemes;
87
    }
88
89 6
    public function hasHeaders(): bool
90
    {
91 6
        return isset($this->headers);
92
    }
93
94 6
    public function hasLinks(): bool
95
    {
96 6
        return isset($this->links);
97
    }
98
99 6
    public function hasParameters(): bool
100
    {
101 6
        return isset($this->parameters);
102
    }
103
104 6
    public function hasRequestBodies(): bool
105
    {
106 6
        return isset($this->requestBodies);
107
    }
108
109 6
    public function hasResponses(): bool
110
    {
111 6
        return isset($this->responses);
112
    }
113
114 6
    public function hasSchemas(): bool
115
    {
116 6
        return isset($this->schemas);
117
    }
118
119 6
    public function hasSecuritySchemes(): bool
120
    {
121 6
        return isset($this->securitySchemes);
122
    }
123
124 6
    public function jsonSerialize(): ?array
125
    {
126 6
        return $this->extendedProperties(parent::jsonSerialize());
127
    }
128
129 6
    protected function normalizeOptionalProperties(): array
130
    {
131
        return [
132 6
            'schemas' => $this->hasSchemas() ? $this->getSchemas()->jsonSerialize() : null,
133 6
            'responses' => $this->hasResponses() ? $this->getResponses()->jsonSerialize() : null,
134 6
            'parameters' => $this->hasParameters() ? $this->getParameters()->jsonSerialize() : null,
135 6
            'requestBodies' => $this->hasRequestBodies() ? $this->getRequestBodies()->jsonSerialize() : null,
136 6
            'headers' => $this->hasHeaders() ? $this->getHeaders()->jsonSerialize() : null,
137 6
            'securitySchemes' => $this->hasSecuritySchemes() ? $this->getSecuritySchemes()->jsonSerialize() : null,
138 6
            'links' => $this->hasLinks() ? $this->getLinks() : null,
139 6
            'callbacks' => $this->getNormalizedCallbacks(),
140 6
            'examples' => $this->getNormalizedExamples(),
141
        ];
142
    }
143
}
144