• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 15063570239

16 May 2025 07:56AM UTC coverage: 27.494% (-0.001%) from 27.495%
15063570239

push

github

web-flow
fix: error formats (#7148)

0 of 2 new or added lines in 2 files covered. (0.0%)

11139 existing lines in 371 files now uncovered.

13476 of 49015 relevant lines covered (27.49%)

74.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

63.89
/src/Metadata/Parameter.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Metadata;
15

16
use ApiPlatform\OpenApi\Model\Parameter as OpenApiParameter;
17
use ApiPlatform\State\ParameterNotFound;
18
use ApiPlatform\State\ParameterProviderInterface;
19
use Symfony\Component\TypeInfo\Type;
20

21
/**
22
 * @experimental
23
 */
24
abstract class Parameter
25
{
26
    /**
27
     * @param (array<string, mixed>&array{type?: string, default?: string})|null $schema
28
     * @param array<string, mixed>                                               $extraProperties
29
     * @param ParameterProviderInterface|callable|string|null                    $provider
30
     * @param list<string>                                                       $properties      a list of properties this parameter applies to (works with the :property placeholder)
31
     * @param FilterInterface|string|null                                        $filter
32
     * @param mixed                                                              $constraints     an array of Symfony constraints, or an array of Laravel rules
33
     * @param Type                                                               $nativeType      the PHP native type, we cast values to an array if its a CollectionType, if not and it's an array with a single value we use it (eg: HTTP Header)
34
     */
35
    public function __construct(
36
        protected ?string $key = null,
37
        protected ?array $schema = null,
38
        protected OpenApiParameter|array|false|null $openApi = null,
39
        protected mixed $provider = null,
40
        protected mixed $filter = null,
41
        protected ?string $property = null,
42
        protected ?string $description = null,
43
        protected ?array $properties = null,
44
        protected ?bool $required = null,
45
        protected ?int $priority = null,
46
        protected ?false $hydra = null,
47
        protected mixed $constraints = null,
48
        protected string|\Stringable|null $security = null,
49
        protected ?string $securityMessage = null,
50
        protected ?array $extraProperties = [],
51
        protected array|string|null $filterContext = null,
52
        protected ?Type $nativeType = null,
53
    ) {
UNCOV
54
    }
172✔
55

56
    public function getKey(): ?string
57
    {
UNCOV
58
        return $this->key;
1,033✔
59
    }
60

61
    /**
62
     * @return (array<string, mixed>&array{type?: string, default?: string})|null $schema
63
     */
64
    public function getSchema(): ?array
65
    {
UNCOV
66
        return $this->schema;
804✔
67
    }
68

69
    /**
70
     * @return OpenApiParameter[]|OpenApiParameter|bool|null
71
     */
72
    public function getOpenApi(): OpenApiParameter|array|bool|null
73
    {
UNCOV
74
        return $this->openApi;
92✔
75
    }
76

77
    public function getProvider(): mixed
78
    {
UNCOV
79
        return $this->provider;
691✔
80
    }
81

82
    public function getProperty(): ?string
83
    {
UNCOV
84
        return $this->property;
582✔
85
    }
86

87
    public function getFilter(): mixed
88
    {
UNCOV
89
        return $this->filter;
862✔
90
    }
91

92
    public function getDescription(): ?string
93
    {
UNCOV
94
        return $this->description;
45✔
95
    }
96

97
    public function getRequired(): ?bool
98
    {
UNCOV
99
        return $this->required;
516✔
100
    }
101

102
    public function getPriority(): ?int
103
    {
UNCOV
104
        return $this->priority;
31✔
105
    }
106

107
    public function getHydra(): ?bool
108
    {
UNCOV
109
        return $this->hydra;
397✔
110
    }
111

112
    public function getConstraints(): mixed
113
    {
UNCOV
114
        return $this->constraints;
757✔
115
    }
116

117
    public function getSecurity(): string|\Stringable|null
118
    {
UNCOV
119
        return $this->security;
700✔
120
    }
121

122
    public function getSecurityMessage(): ?string
123
    {
UNCOV
124
        return $this->securityMessage;
20✔
125
    }
126

127
    /**
128
     * The computed value of this parameter, located into extraProperties['_api_values'].
129
     */
130
    public function getValue(mixed $default = new ParameterNotFound()): mixed
131
    {
UNCOV
132
        return $this->extraProperties['_api_values'] ?? $default;
788✔
133
    }
134

135
    public function setValue(mixed $value): static
136
    {
137
        $this->extraProperties['_api_values'] = $value;
×
138

139
        return $this;
×
140
    }
141

142
    /**
143
     * @return array<string, mixed>
144
     */
145
    public function getExtraProperties(): array
146
    {
UNCOV
147
        return $this->extraProperties;
1,039✔
148
    }
149

150
    public function getFilterContext(): array|string|null
151
    {
UNCOV
152
        return $this->filterContext;
154✔
153
    }
154

155
    public function withKey(string $key): static
156
    {
UNCOV
157
        $self = clone $this;
31✔
UNCOV
158
        $self->key = $key;
31✔
159

UNCOV
160
        return $self;
31✔
161
    }
162

163
    public function withPriority(int $priority): static
164
    {
UNCOV
165
        $self = clone $this;
31✔
UNCOV
166
        $self->priority = $priority;
31✔
167

UNCOV
168
        return $self;
31✔
169
    }
170

171
    /**
172
     * @param array{type?: string} $schema
173
     */
174
    public function withSchema(array $schema): static
175
    {
UNCOV
176
        $self = clone $this;
21✔
UNCOV
177
        $self->schema = $schema;
21✔
178

UNCOV
179
        return $self;
21✔
180
    }
181

182
    /**
183
     * @param OpenApiParameter[]|OpenApiParameter|bool $openApi
184
     */
185
    public function withOpenApi(OpenApiParameter|array|bool $openApi): static
186
    {
UNCOV
187
        $self = clone $this;
13✔
UNCOV
188
        $self->openApi = $openApi;
13✔
189

UNCOV
190
        return $self;
13✔
191
    }
192

193
    /**
194
     * @param ParameterProviderInterface|string $provider
195
     */
196
    public function withProvider(mixed $provider): static
197
    {
UNCOV
198
        $self = clone $this;
4✔
UNCOV
199
        $self->provider = $provider;
4✔
200

UNCOV
201
        return $self;
4✔
202
    }
203

204
    /**
205
     * @param FilterInterface|string $filter
206
     */
207
    public function withFilter(mixed $filter): static
208
    {
209
        $self = clone $this;
×
210
        $self->filter = $filter;
×
211

212
        return $self;
×
213
    }
214

215
    public function withFilterContext(array|string $filterContext): static
216
    {
217
        $self = clone $this;
×
218
        $self->filterContext = $filterContext;
×
219

220
        return $self;
×
221
    }
222

223
    public function withProperty(string $property): static
224
    {
UNCOV
225
        $self = clone $this;
23✔
UNCOV
226
        $self->property = $property;
23✔
227

UNCOV
228
        return $self;
23✔
229
    }
230

231
    public function withDescription(string $description): static
232
    {
233
        $self = clone $this;
×
234
        $self->description = $description;
×
235

236
        return $self;
×
237
    }
238

239
    public function withRequired(bool $required): static
240
    {
241
        $self = clone $this;
×
242
        $self->required = $required;
×
243

244
        return $self;
×
245
    }
246

247
    public function withHydra(false $hydra): static
248
    {
249
        $self = clone $this;
×
250
        $self->hydra = $hydra;
×
251

252
        return $self;
×
253
    }
254

255
    public function withConstraints(mixed $constraints): static
256
    {
UNCOV
257
        $self = clone $this;
27✔
UNCOV
258
        $self->constraints = $constraints;
27✔
259

UNCOV
260
        return $self;
27✔
261
    }
262

263
    public function withSecurity(string|\Stringable|null $security): static
264
    {
265
        $self = clone $this;
×
266
        $self->security = $security;
×
267

268
        return $self;
×
269
    }
270

271
    public function withSecurityMessage(?string $securityMessage): static
272
    {
273
        $self = clone $this;
×
274
        $self->securityMessage = $securityMessage;
×
275

276
        return $self;
×
277
    }
278

279
    /**
280
     * @param array<string, mixed> $extraProperties
281
     */
282
    public function withExtraProperties(array $extraProperties): static
283
    {
UNCOV
284
        $self = clone $this;
754✔
UNCOV
285
        $self->extraProperties = $extraProperties;
754✔
286

UNCOV
287
        return $self;
754✔
288
    }
289

290
    public function getProperties(): ?array
291
    {
UNCOV
292
        return $this->properties;
61✔
293
    }
294

295
    public function withProperties(?array $properties): self
296
    {
297
        $self = clone $this;
×
298
        $self->properties = $properties;
×
299

300
        return $self;
×
301
    }
302

303
    public function getNativeType(): ?Type
304
    {
UNCOV
305
        return $this->nativeType;
505✔
306
    }
307

308
    public function withNativeType(Type $nativeType): self
309
    {
UNCOV
310
        $self = clone $this;
27✔
UNCOV
311
        $self->nativeType = $nativeType;
27✔
312

UNCOV
313
        return $self;
27✔
314
    }
315
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc