/
Parameter.php
191 lines (156 loc) · 3.96 KB
/
Parameter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?php
/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <dunglas@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace ApiPlatform\Metadata;
use ApiPlatform\OpenApi;
use ApiPlatform\State\ProviderInterface;
/**
* @experimental
*/
abstract class Parameter
{
/**
* @param array{type?: string}|null $schema
* @param array<string, mixed> $extraProperties
* @param ProviderInterface|callable|string|null $provider
* @param FilterInterface|string|null $filter
*/
public function __construct(
protected ?string $key = null,
protected ?array $schema = null,
protected ?OpenApi\Model\Parameter $openApi = null,
protected mixed $provider = null,
protected mixed $filter = null,
protected ?string $property = null,
protected ?string $description = null,
protected ?bool $required = null,
protected ?int $priority = null,
protected ?array $extraProperties = [],
) {
}
public function getKey(): ?string
{
return $this->key;
}
/**
* @return array{type?: string}|null $schema
*/
public function getSchema(): ?array
{
return $this->schema;
}
public function getOpenApi(): ?OpenApi\Model\Parameter
{
return $this->openApi;
}
public function getProvider(): mixed
{
return $this->provider;
}
public function getProperty(): ?string
{
return $this->property;
}
public function getFilter(): mixed
{
return $this->filter;
}
public function getDescription(): ?string
{
return $this->description;
}
public function getRequired(): ?bool
{
return $this->required;
}
public function getPriority(): ?int
{
return $this->priority;
}
/**
* @return array<string, mixed>
*/
public function getExtraProperties(): array
{
return $this->extraProperties;
}
public function withKey(string $key): static
{
$self = clone $this;
$self->key = $key;
return $self;
}
public function withPriority(int $priority): static
{
$self = clone $this;
$self->priority = $priority;
return $self;
}
/**
* @param array{type?: string} $schema
*/
public function withSchema(array $schema): static
{
$self = clone $this;
$self->schema = $schema;
return $self;
}
public function withOpenApi(OpenApi\Model\Parameter $openApi): static
{
$self = clone $this;
$self->openApi = $openApi;
return $self;
}
/**
* @param ProviderInterface|string $provider
*/
public function withProvider(mixed $provider): static
{
$self = clone $this;
$self->provider = $provider;
return $self;
}
/**
* @param FilterInterface|string $filter
*/
public function withFilter(mixed $filter): static
{
$self = clone $this;
$self->filter = $filter;
return $self;
}
public function withProperty(string $property): static
{
$self = clone $this;
$self->property = $property;
return $self;
}
public function withDescription(string $description): static
{
$self = clone $this;
$self->description = $description;
return $self;
}
public function withRequired(bool $required): static
{
$self = clone $this;
$self->required = $required;
return $self;
}
/**
* @param array<string, mixed> $extraProperties
*/
public function withExtraProperties(array $extraProperties): static
{
$self = clone $this;
$self->extraProperties = $extraProperties;
return $self;
}
}