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

ParameterBuilder   A

Complexity

Total Complexity 29

Size/Duplication

Total Lines 196
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 29
lcom 1
cbo 5
dl 0
loc 196
rs 10
c 0
b 0
f 0

26 Methods

Rating   Name   Duplication   Size   Complexity  
A createParameter() 0 18 4
A createParameterAggregate() 0 4 1
A setAllowEmptyValue() 0 6 1
A setAllowReserved() 0 6 1
A setContent() 0 6 1
A setDeprecated() 0 6 1
A setDescription() 0 6 1
A setExamples() 0 6 1
A setExplode() 0 6 1
A setIn() 0 6 1
A setName() 0 6 1
A setRequired() 0 6 1
A setSchema() 0 6 1
A setStyle() 0 6 1
A getContent() 0 4 1
A getDescription() 0 4 1
A getExamples() 0 4 1
A getIn() 0 4 1
A getName() 0 4 1
A getSchema() 0 4 1
A getStyle() 0 4 1
A isAllowEmptyValue() 0 4 1
A isAllowReserved() 0 4 1
A isDeprecated() 0 4 1
A isExplode() 0 4 1
A isRequired() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Aweapi\Openapi\Builders;
6
7
use Aweapi\Openapi\Objects;
8
use Aweapi\Openapi\Objects\ParameterAggregate;
9
10
final class ParameterBuilder implements Objects\ParameterFactory
11
{
12
    use Properties\OptionalExtensions;
13
14
    private $allowEmptyValue = false;
15
16
    private $allowReserved = false;
17
18
    private $content;
19
20
    private $deprecated = false;
21
22
    private $description;
23
24
    private $examples;
25
26
    private $explode;
27
28
    private $in;
29
30
    private $name;
31
32
    private $required;
33
34
    private $schema;
35
36
    private $style;
37
38
    public function createParameter(): Objects\Parameter
39
    {
40
        return new Objects\Parameter(
41
            $this->getName(),
42
            $this->getIn(),
43
            $this->getSchema() ? $this->getSchema()->createSchemaAggregate() : null,
44
            $this->getContent() ? $this->getContent()->createMediaTypes() : null,
45
            $this->getDescription(),
46
            $this->isRequired(),
47
            $this->isDeprecated(),
48
            $this->isAllowEmptyValue(),
49
            $this->getStyle(),
50
            $this->isExplode(),
51
            $this->isAllowReserved(),
52
            $this->getExamples() ? $this->getExamples()->createExamples() : null,
53
            $this->getExtensions()
54
        );
55
    }
56
57
    public function createParameterAggregate(): ParameterAggregate
58
    {
59
        return $this->createParameter();
60
    }
61
62
    public function setAllowEmptyValue(bool $allowEmptyValue): self
63
    {
64
        $this->allowEmptyValue = $allowEmptyValue;
65
66
        return $this;
67
    }
68
69
    public function setAllowReserved(bool $allowReserved): self
70
    {
71
        $this->allowReserved = $allowReserved;
72
73
        return $this;
74
    }
75
76
    public function setContent(Objects\MediaTypesFactory $content): self
77
    {
78
        $this->content = $content;
79
80
        return $this;
81
    }
82
83
    public function setDeprecated(bool $deprecated): self
84
    {
85
        $this->deprecated = $deprecated;
86
87
        return $this;
88
    }
89
90
    public function setDescription(string $description): self
91
    {
92
        $this->description = $description;
93
94
        return $this;
95
    }
96
97
    public function setExamples(Objects\ExamplesFactory $examples): self
98
    {
99
        $this->examples = $examples;
100
101
        return $this;
102
    }
103
104
    public function setExplode($explode): self
105
    {
106
        $this->explode = $explode;
107
108
        return $this;
109
    }
110
111
    public function setIn(string $in): self
112
    {
113
        $this->in = $in;
114
115
        return $this;
116
    }
117
118
    public function setName(string $name): self
119
    {
120
        $this->name = $name;
121
122
        return $this;
123
    }
124
125
    public function setRequired(bool $required): self
126
    {
127
        $this->required = $required;
128
129
        return $this;
130
    }
131
132
    public function setSchema(Objects\SchemaAggregateFactory $schema): self
133
    {
134
        $this->schema = $schema;
135
136
        return $this;
137
    }
138
139
    public function setStyle($style): self
140
    {
141
        $this->style = $style;
142
143
        return $this;
144
    }
145
146
    private function getContent(): ?Objects\MediaTypesFactory
147
    {
148
        return $this->content;
149
    }
150
151
    private function getDescription(): ?string
152
    {
153
        return $this->description;
154
    }
155
156
    private function getExamples(): ?Objects\ExamplesFactory
157
    {
158
        return $this->examples;
159
    }
160
161
    private function getIn(): string
162
    {
163
        return $this->in;
164
    }
165
166
    private function getName(): string
167
    {
168
        return $this->name;
169
    }
170
171
    private function getSchema(): ?Objects\SchemaAggregateFactory
172
    {
173
        return $this->schema;
174
    }
175
176
    private function getStyle(): ?string
177
    {
178
        return $this->style;
179
    }
180
181
    private function isAllowEmptyValue(): bool
182
    {
183
        return $this->allowEmptyValue;
184
    }
185
186
    private function isAllowReserved(): bool
187
    {
188
        return $this->allowReserved;
189
    }
190
191
    private function isDeprecated(): bool
192
    {
193
        return $this->deprecated;
194
    }
195
196
    private function isExplode(): ?bool
197
    {
198
        return $this->explode;
199
    }
200
201
    private function isRequired(): ?bool
202
    {
203
        return $this->required;
204
    }
205
}
206