Completed
Pull Request — master (#6)
by Veaceslav
11:19
created

OperationBuilder::isDeprecated()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Aweapi\Openapi\Builders;
6
7
use Aweapi\Openapi\Objects;
8
9
final class OperationBuilder implements Objects\OperationFactory
10
{
11
    use Properties\OptionalExtensions;
12
13
    private $callbacks;
14
15
    private $deprecated = false;
16
17
    private $description;
18
19
    private $externalDocs;
20
21
    private $operationId;
22
23
    private $parameters;
24
25
    private $requestBody;
26
27
    private $responses;
28
29
    private $security;
30
31
    private $servers;
32
33
    private $summary;
34
35
    private $tags = [];
36
37
    public function createOperation(): Objects\Operation
38
    {
39
        return new Objects\Operation(
40
            $this->getResponses() ? $this->getResponses()->createOperationResponses() : null,
41
            $this->getRequestBody() ? $this->getRequestBody()->createRequestBodyAggregate() : null,
42
            $this->getTags(),
43
            $this->getOperationId(),
44
            $this->getSummary(),
45
            $this->getDescription(),
46
            $this->isDeprecated(),
47
            $this->getParameters() ? $this->getParameters()->createParameterCollection() : null,
48
            $this->getSecurity() ? $this->getSecurity()->createSecurityRequirementCollection() : null,
49
            null,
50
            $this->getServers() ? $this->getServers()->createServerCollection() : null,
51
            $this->getExternalDocs() ? $this->getExternalDocs()->createExternalDocumentation() : null,
52
            $this->getExtensions()
53
        );
54
    }
55
56
    public function setDeprecated(bool $deprecated): self
57
    {
58
        $this->deprecated = $deprecated;
59
60
        return $this;
61
    }
62
63
    public function setDescription(string $description): self
64
    {
65
        $this->description = $description;
66
67
        return $this;
68
    }
69
70
    public function setExternalDocs(Objects\ExternalDocumentationFactory $externalDocs): self
71
    {
72
        $this->externalDocs = $externalDocs;
73
74
        return $this;
75
    }
76
77
    public function setOperationId(string $operationId): self
78
    {
79
        $this->operationId = $operationId;
80
81
        return $this;
82
    }
83
84
    public function setParameters(Objects\ParameterCollectionFactory $parameters): self
85
    {
86
        $this->parameters = $parameters;
87
88
        return $this;
89
    }
90
91
    public function setRequestBody(Objects\RequestBodyFactory $requestBody): self
92
    {
93
        $this->requestBody = $requestBody;
94
95
        return $this;
96
    }
97
98
    public function setResponses(Objects\OperationResponsesFactory $responses): self
99
    {
100
        $this->responses = $responses;
101
102
        return $this;
103
    }
104
105
    public function setSecurity(Objects\SecurityRequirementCollectionFactory $security): self
106
    {
107
        $this->security = $security;
108
109
        return $this;
110
    }
111
112
    public function setServers(Objects\ServerCollectionFactory $servers): self
113
    {
114
        $this->servers = $servers;
115
116
        return $this;
117
    }
118
119
    public function setSummary(string $summary): self
120
    {
121
        $this->summary = $summary;
122
123
        return $this;
124
    }
125
126
    public function setTags(array $tags): self
127
    {
128
        $this->tags = $tags;
129
130
        return $this;
131
    }
132
133
    private function getDescription(): ?string
134
    {
135
        return $this->description;
136
    }
137
138
    private function getExternalDocs(): ?Objects\ExternalDocumentationFactory
139
    {
140
        return $this->externalDocs;
141
    }
142
143
    private function getOperationId(): ?string
144
    {
145
        return $this->operationId;
146
    }
147
148
    private function getParameters(): ?Objects\ParameterCollectionFactory
149
    {
150
        return $this->parameters;
151
    }
152
153
    private function getRequestBody(): ?Objects\RequestBodyFactory
154
    {
155
        return $this->requestBody;
156
    }
157
158
    private function getResponses(): ?Objects\OperationResponsesFactory
159
    {
160
        return $this->responses;
161
    }
162
163
    private function getSecurity(): ?Objects\SecurityRequirementCollectionFactory
164
    {
165
        return $this->security;
166
    }
167
168
    private function getServers(): ?Objects\ServerCollectionFactory
169
    {
170
        return $this->servers;
171
    }
172
173
    private function getSummary(): ?string
174
    {
175
        return $this->summary;
176
    }
177
178
    private function getTags(): array
179
    {
180
        return $this->tags;
181
    }
182
183
    private function isDeprecated(): bool
184
    {
185
        return $this->deprecated;
186
    }
187
}
188