Passed
Pull Request — master (#34)
by Anatoly
02:19
created

Schema::getComponentName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php declare(strict_types=1);
2
3
/**
4
 * It's free open-source software released under the MIT License.
5
 *
6
 * @author Anatoly Fenric <[email protected]>
7
 * @copyright Copyright (c) 2018, Anatoly Fenric
8
 * @license https://github.com/sunrise-php/http-router/blob/master/LICENSE
9
 * @link https://github.com/sunrise-php/http-router
10
 */
11
12
namespace Sunrise\Http\Router\Annotation\OpenApi;
13
14
/**
15
 * Import classes
16
 */
17
use Sunrise\Http\Router\OpenApi\ComponentObjectInterface;
18
19
/**
20
 * Import functions
21
 */
22
use function spl_object_hash;
23
24
/**
25
 * @Annotation
26
 *
27
 * @Target({"ALL"})
28
 *
29
 * @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#schema-object
30
 * @link https://json-schema.org/draft/2019-09/json-schema-validation.html
31
 */
32
final class Schema extends AbstractAnnotation implements SchemaInterface, ComponentObjectInterface
33
{
34
35
    /**
36
     * {@inheritDoc}
37
     */
38
    protected const IGNORE_FIELDS = ['refName'];
39
40
    /**
41
     * @var string
42
     */
43
    public $refName;
44
45
    /**
46
     * @var \Sunrise\Http\Router\Annotation\OpenApi\SchemaInterface
47
     */
48
    public $additionalProperties;
49
50
    /**
51
     * @var array<\Sunrise\Http\Router\Annotation\OpenApi\SchemaInterface>
52
     */
53
    public $allOf;
54
55
    /**
56
     * @var array<\Sunrise\Http\Router\Annotation\OpenApi\SchemaInterface>
57
     */
58
    public $anyOf;
59
60
    /**
61
     * @var mixed
62
     */
63
    public $default;
64
65
    /**
66
     * @var bool
67
     *
68
     * @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-schemadeprecated
69
     */
70
    public $deprecated;
71
72
    /**
73
     * @var string
74
     */
75
    public $description;
76
77
    /**
78
     * @var \Sunrise\Http\Router\Annotation\OpenApi\DiscriminatorInterface
79
     *
80
     * @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-schemadiscriminator
81
     */
82
    public $discriminator;
83
84
    /**
85
     * @var array
86
     *
87
     * @link https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.1.2
88
     */
89
    public $enum;
90
91
    /**
92
     * @var mixed
93
     *
94
     * @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-schemaexample
95
     */
96
    public $example;
97
98
    /**
99
     * @var int
100
     *
101
     * @link https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.2.3
102
     */
103
    public $exclusiveMaximum;
104
105
    /**
106
     * @var int
107
     *
108
     * @link https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.2.5
109
     */
110
    public $exclusiveMinimum;
111
112
    /**
113
     * @var \Sunrise\Http\Router\Annotation\OpenApi\ExternalDocumentationInterface
114
     *
115
     * @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-schemaexternaldocs
116
     */
117
    public $externalDocs;
118
119
    /**
120
     * @var string
121
     */
122
    public $format;
123
124
    /**
125
     * @var \Sunrise\Http\Router\Annotation\OpenApi\SchemaInterface
126
     */
127
    public $items;
128
129
    /**
130
     * @var int
131
     *
132
     * @link https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.2.2
133
     */
134
    public $maximum;
135
136
    /**
137
     * @var int
138
     *
139
     * @link https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.4.1
140
     */
141
    public $maxItems;
142
143
    /**
144
     * @var int
145
     *
146
     * @link https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.3.1
147
     */
148
    public $maxLength;
149
150
    /**
151
     * @var int
152
     *
153
     * @link https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.5.1
154
     */
155
    public $maxProperties;
156
157
    /**
158
     * @var int
159
     *
160
     * @link https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.2.4
161
     */
162
    public $minimum;
163
164
    /**
165
     * @var int
166
     *
167
     * @link https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.4.2
168
     */
169
    public $minItems;
170
171
    /**
172
     * @var int
173
     *
174
     * @link https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.3.2
175
     */
176
    public $minLength;
177
178
    /**
179
     * @var int
180
     *
181
     * @link https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.5.2
182
     */
183
    public $minProperties;
184
185
    /**
186
     * @var int
187
     *
188
     * @link https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.2.1
189
     */
190
    public $multipleOf;
191
192
    /**
193
     * @var \Sunrise\Http\Router\Annotation\OpenApi\SchemaInterface
194
     */
195
    public $not;
196
197
    /**
198
     * @var bool
199
     *
200
     * @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-schemanullable
201
     */
202
    public $nullable;
203
204
    /**
205
     * @var array<\Sunrise\Http\Router\Annotation\OpenApi\SchemaInterface>
206
     */
207
    public $oneOf;
208
209
    /**
210
     * @var string
211
     *
212
     * @link https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.3.3
213
     */
214
    public $pattern;
215
216
    /**
217
     * @var array<\Sunrise\Http\Router\Annotation\OpenApi\SchemaInterface>
218
     */
219
    public $properties;
220
221
    /**
222
     * @var bool
223
     *
224
     * @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-schemareadonly
225
     */
226
    public $readOnly;
227
228
    /**
229
     * @var array<string>
230
     *
231
     * @link https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.5.3
232
     */
233
    public $required;
234
235
    /**
236
     * @var string
237
     *
238
     * @link https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.9.1
239
     */
240
    public $title;
241
242
    /**
243
     * @var string
244
     */
245
    public $type;
246
247
    /**
248
     * @var bool
249
     *
250
     * @link https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.4.3
251
     */
252
    public $uniqueItems;
253
254
    /**
255
     * @var bool
256
     *
257
     * @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-schemawriteonly
258
     */
259
    public $writeOnly;
260
261
    /**
262
     * @var \Sunrise\Http\Router\Annotation\OpenApi\XmlInterface
263
     *
264
     * @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-schemaxml
265
     */
266
    public $xml;
267
268
    /**
269
     * {@inheritDoc}
270
     */
271 1
    public function getComponentName() : string
272
    {
273 1
        return 'schemas';
274
    }
275
276
    /**
277
     * {@inheritDoc}
278
     */
279 2
    public function getReferenceName() : string
280
    {
281 2
        return $this->refName ?? spl_object_hash($this);
282
    }
283
}
284