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

api-platform / core / 4498909317

pending completion
4498909317

push

github

soyuka
Merge 3.1

364 of 364 new or added lines in 61 files covered. (100.0%)

10781 of 17989 relevant lines covered (59.93%)

11.36 hits per line

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

94.19
/src/Metadata/HttpOperation.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\Operation as OpenApiOperation;
17
use ApiPlatform\State\OptionsInterface;
18

19
class HttpOperation extends Operation
20
{
21
    public const METHOD_GET = 'GET';
22
    public const METHOD_POST = 'POST';
23
    public const METHOD_PUT = 'PUT';
24
    public const METHOD_PATCH = 'PATCH';
25
    public const METHOD_DELETE = 'DELETE';
26
    public const METHOD_HEAD = 'HEAD';
27
    public const METHOD_OPTIONS = 'OPTIONS';
28

29
    /**
30
     * @param string[]|null                                  $types         the RDF types of this property
31
     * @param array<int|string, string|string[]>|string|null $formats       {@see https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation}
32
     * @param array<int|string, string|string[]>|string|null $inputFormats  {@see https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation}
33
     * @param array<int|string, string|string[]>|string|null $outputFormats {@see https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation}
34
     * @param array<string,array{
35
     *     0: string,
36
     *     1: string
37
     * }|array{
38
     *     from_property?: string,
39
     *     to_property?: string,
40
     *     from_class?: string,
41
     *     to_class?: string,
42
     *     identifiers?: string[],
43
     *     composite_identifier?: bool,
44
     *     expanded_value?: string,
45
     * }|Link>|string[]|string|null $uriVariables {@see https://api-platform.com/docs/core/subresources/}
46
     * @param string|null     $routePrefix {@see https://api-platform.com/docs/core/operations/#prefixing-all-routes-of-all-operations}
47
     * @param string|null     $sunset      {@see https://api-platform.com/docs/core/deprecations/#setting-the-sunset-http-header-to-indicate-when-a-resource-or-an-operation-will-be-removed}
48
     * @param string|int|null $status      {@see https://api-platform.com/docs/core/operations/#configuring-operations}
49
     * @param array{
50
     *     max_age?: int,
51
     *     vary?: string|string[],
52
     *     public?: bool,
53
     *     shared_max_age?: int,
54
     *     stale_while_revalidate?: int,
55
     *     stale-if-error?: int,
56
     * }|null $cacheHeaders {@see https://api-platform.com/docs/core/performance/#setting-custom-http-cache-headers}
57
     * @param array{
58
     *     field: string,
59
     *     direction: string,
60
     * }|null $paginationViaCursor {@see https://api-platform.com/docs/core/pagination/#cursor-based-pagination}
61
     * @param array|null $normalizationContext   {@see https://api-platform.com/docs/core/serialization/#using-serialization-groups}
62
     * @param array|null $denormalizationContext {@see https://api-platform.com/docs/core/serialization/#using-serialization-groups}
63
     * @param array|null $hydraContext           {@see https://api-platform.com/docs/core/extending-jsonld-context/#hydra}
64
     * @param array|null $openapiContext         {@see https://api-platform.com/docs/core/openapi/#using-the-openapi-and-swagger-contexts}
65
     * @param array{
66
     *     class?: string|null,
67
     *     name?: string,
68
     * }|string|false|null $input {@see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation}
69
     * @param array{
70
     *     class?: string|null,
71
     *     name?: string,
72
     * }|string|false|null $output {@see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation}
73
     * @param string|array|bool|null $mercure   {@see https://api-platform.com/docs/core/mercure}
74
     * @param string|bool|null       $messenger {@see https://api-platform.com/docs/core/messenger/#dispatching-a-resource-through-the-message-bus}
75
     * @param string|callable|null   $provider  {@see https://api-platform.com/docs/core/state-providers/#state-providers}
76
     * @param string|callable|null   $processor {@see https://api-platform.com/docs/core/state-processors/#state-processors}
77
     */
78
    public function __construct(
79
        protected string $method = self::METHOD_GET,
80
        protected ?string $uriTemplate = null,
81
        protected ?array $types = null,
82
        protected $formats = null,
83
        protected $inputFormats = null,
84
        protected $outputFormats = null,
85
        protected $uriVariables = null,
86
        protected ?string $routePrefix = null,
87
        protected ?string $routeName = null,
88
        protected ?array $defaults = null,
89
        protected ?array $requirements = null,
90
        protected ?array $options = null,
91
        protected ?bool $stateless = null,
92
        protected ?string $sunset = null,
93
        protected ?string $acceptPatch = null,
94
        protected $status = null,
95
        protected ?string $host = null,
96
        protected ?array $schemes = null,
97
        protected ?string $condition = null,
98
        protected ?string $controller = null,
99
        protected ?array $cacheHeaders = null,
100
        protected ?array $paginationViaCursor = null,
101
        protected ?array $hydraContext = null,
102
        protected ?array $openapiContext = null, // TODO Remove in 4.0
103
        protected bool|OpenApiOperation|null $openapi = null,
104
        protected ?array $exceptionToStatus = null,
105
        protected ?bool $queryParameterValidationEnabled = null,
106

107
        ?string $shortName = null,
108
        ?string $class = null,
109
        ?bool $paginationEnabled = null,
110
        ?string $paginationType = null,
111
        ?int $paginationItemsPerPage = null,
112
        ?int $paginationMaximumItemsPerPage = null,
113
        ?bool $paginationPartial = null,
114
        ?bool $paginationClientEnabled = null,
115
        ?bool $paginationClientItemsPerPage = null,
116
        ?bool $paginationClientPartial = null,
117
        ?bool $paginationFetchJoinCollection = null,
118
        ?bool $paginationUseOutputWalkers = null,
119
        ?array $order = null,
120
        ?string $description = null,
121
        ?array $normalizationContext = null,
122
        ?array $denormalizationContext = null,
123
        ?bool $collectDenormalizationErrors = null,
124
        ?string $security = null,
125
        ?string $securityMessage = null,
126
        ?string $securityPostDenormalize = null,
127
        ?string $securityPostDenormalizeMessage = null,
128
        ?string $securityPostValidation = null,
129
        ?string $securityPostValidationMessage = null,
130
        ?string $deprecationReason = null,
131
        ?array $filters = null,
132
        ?array $validationContext = null,
133
        $input = null,
134
        $output = null,
135
        $mercure = null,
136
        $messenger = null,
137
        ?bool $elasticsearch = null,
138
        ?int $urlGenerationStrategy = null,
139
        ?bool $read = null,
140
        ?bool $deserialize = null,
141
        ?bool $validate = null,
142
        ?bool $write = null,
143
        ?bool $serialize = null,
144
        ?bool $fetchPartial = null,
145
        ?bool $forceEager = null,
146
        ?int $priority = null,
147
        ?string $name = null,
148
        $provider = null,
149
        $processor = null,
150
        ?OptionsInterface $stateOptions = null,
151
        array $extraProperties = [],
152
    ) {
153
        parent::__construct(
306✔
154
            shortName: $shortName,
306✔
155
            class: $class,
306✔
156
            paginationEnabled: $paginationEnabled,
306✔
157
            paginationType: $paginationType,
306✔
158
            paginationItemsPerPage: $paginationItemsPerPage,
306✔
159
            paginationMaximumItemsPerPage: $paginationMaximumItemsPerPage,
306✔
160
            paginationPartial: $paginationPartial,
306✔
161
            paginationClientEnabled: $paginationClientEnabled,
306✔
162
            paginationClientItemsPerPage: $paginationClientItemsPerPage,
306✔
163
            paginationClientPartial: $paginationClientPartial,
306✔
164
            paginationFetchJoinCollection: $paginationFetchJoinCollection,
306✔
165
            paginationUseOutputWalkers: $paginationUseOutputWalkers,
306✔
166
            order: $order,
306✔
167
            description: $description,
306✔
168
            normalizationContext: $normalizationContext,
306✔
169
            denormalizationContext: $denormalizationContext,
306✔
170
            collectDenormalizationErrors: $collectDenormalizationErrors,
306✔
171
            security: $security,
306✔
172
            securityMessage: $securityMessage,
306✔
173
            securityPostDenormalize: $securityPostDenormalize,
306✔
174
            securityPostDenormalizeMessage: $securityPostDenormalizeMessage,
306✔
175
            securityPostValidation: $securityPostValidation,
306✔
176
            securityPostValidationMessage: $securityPostValidationMessage,
306✔
177
            deprecationReason: $deprecationReason,
306✔
178
            filters: $filters,
306✔
179
            validationContext: $validationContext,
306✔
180
            input: $input,
306✔
181
            output: $output,
306✔
182
            mercure: $mercure,
306✔
183
            messenger: $messenger,
306✔
184
            elasticsearch: $elasticsearch,
306✔
185
            urlGenerationStrategy: $urlGenerationStrategy,
306✔
186
            read: $read,
306✔
187
            deserialize: $deserialize,
306✔
188
            validate: $validate,
306✔
189
            write: $write,
306✔
190
            serialize: $serialize,
306✔
191
            fetchPartial: $fetchPartial,
306✔
192
            forceEager: $forceEager,
306✔
193
            priority: $priority,
306✔
194
            name: $name,
306✔
195
            provider: $provider,
306✔
196
            processor: $processor,
306✔
197
            stateOptions: $stateOptions,
306✔
198
            extraProperties: $extraProperties
306✔
199
        );
306✔
200
    }
201

202
    public function getMethod(): string
203
    {
204
        return $this->method;
202✔
205
    }
206

207
    public function withMethod(string $method): self
208
    {
209
        $self = clone $this;
1✔
210
        $self->method = $method;
1✔
211

212
        return $self;
1✔
213
    }
214

215
    public function getUriTemplate(): ?string
216
    {
217
        return $this->uriTemplate;
64✔
218
    }
219

220
    public function withUriTemplate(?string $uriTemplate = null)
221
    {
222
        $self = clone $this;
11✔
223
        $self->uriTemplate = $uriTemplate;
11✔
224

225
        return $self;
11✔
226
    }
227

228
    public function getTypes(): ?array
229
    {
230
        return $this->types;
44✔
231
    }
232

233
    /**
234
     * @param string[]|string $types
235
     */
236
    public function withTypes($types): self
237
    {
238
        $self = clone $this;
4✔
239
        $self->types = (array) $types;
4✔
240

241
        return $self;
4✔
242
    }
243

244
    public function getFormats()
245
    {
246
        return $this->formats;
10✔
247
    }
248

249
    public function withFormats($formats = null): self
250
    {
251
        $self = clone $this;
1✔
252
        $self->formats = $formats;
1✔
253

254
        return $self;
1✔
255
    }
256

257
    public function getInputFormats()
258
    {
259
        return $this->inputFormats;
23✔
260
    }
261

262
    public function withInputFormats($inputFormats = null): self
263
    {
264
        $self = clone $this;
5✔
265
        $self->inputFormats = $inputFormats;
5✔
266

267
        return $self;
5✔
268
    }
269

270
    public function getOutputFormats()
271
    {
272
        return $this->outputFormats;
37✔
273
    }
274

275
    public function withOutputFormats($outputFormats = null): self
276
    {
277
        $self = clone $this;
3✔
278
        $self->outputFormats = $outputFormats;
3✔
279

280
        return $self;
3✔
281
    }
282

283
    public function getUriVariables()
284
    {
285
        return $this->uriVariables;
51✔
286
    }
287

288
    public function withUriVariables($uriVariables): self
289
    {
290
        $self = clone $this;
15✔
291
        $self->uriVariables = $uriVariables;
15✔
292

293
        return $self;
15✔
294
    }
295

296
    public function getRoutePrefix(): ?string
297
    {
298
        return $this->routePrefix;
14✔
299
    }
300

301
    public function withRoutePrefix(string $routePrefix): self
302
    {
303
        $self = clone $this;
2✔
304
        $self->routePrefix = $routePrefix;
2✔
305

306
        return $self;
2✔
307
    }
308

309
    public function getRouteName(): ?string
310
    {
311
        return $this->routeName;
14✔
312
    }
313

314
    public function withRouteName(?string $routeName): self
315
    {
316
        $self = clone $this;
×
317
        $self->routeName = $routeName;
×
318

319
        return $self;
×
320
    }
321

322
    public function getDefaults(): ?array
323
    {
324
        return $this->defaults;
14✔
325
    }
326

327
    public function withDefaults(array $defaults): self
328
    {
329
        $self = clone $this;
2✔
330
        $self->defaults = $defaults;
2✔
331

332
        return $self;
2✔
333
    }
334

335
    public function getRequirements(): ?array
336
    {
337
        return $this->requirements;
14✔
338
    }
339

340
    public function withRequirements(array $requirements): self
341
    {
342
        $self = clone $this;
2✔
343
        $self->requirements = $requirements;
2✔
344

345
        return $self;
2✔
346
    }
347

348
    public function getOptions(): ?array
349
    {
350
        return $this->options;
14✔
351
    }
352

353
    public function withOptions(array $options): self
354
    {
355
        $self = clone $this;
1✔
356
        $self->options = $options;
1✔
357

358
        return $self;
1✔
359
    }
360

361
    public function getStateless(): ?bool
362
    {
363
        return $this->stateless;
14✔
364
    }
365

366
    public function withStateless($stateless): self
367
    {
368
        $self = clone $this;
1✔
369
        $self->stateless = $stateless;
1✔
370

371
        return $self;
1✔
372
    }
373

374
    public function getSunset(): ?string
375
    {
376
        return $this->sunset;
28✔
377
    }
378

379
    public function withSunset(string $sunset): self
380
    {
381
        $self = clone $this;
1✔
382
        $self->sunset = $sunset;
1✔
383

384
        return $self;
1✔
385
    }
386

387
    public function getAcceptPatch(): ?string
388
    {
389
        return $this->acceptPatch;
28✔
390
    }
391

392
    public function withAcceptPatch(string $acceptPatch): self
393
    {
394
        $self = clone $this;
2✔
395
        $self->acceptPatch = $acceptPatch;
2✔
396

397
        return $self;
2✔
398
    }
399

400
    public function getStatus(): ?int
401
    {
402
        return $this->status;
48✔
403
    }
404

405
    public function withStatus(int $status): self
406
    {
407
        $self = clone $this;
5✔
408
        $self->status = $status;
5✔
409

410
        return $self;
5✔
411
    }
412

413
    public function getHost(): ?string
414
    {
415
        return $this->host;
14✔
416
    }
417

418
    public function withHost(string $host): self
419
    {
420
        $self = clone $this;
1✔
421
        $self->host = $host;
1✔
422

423
        return $self;
1✔
424
    }
425

426
    public function getSchemes(): ?array
427
    {
428
        return $this->schemes;
14✔
429
    }
430

431
    public function withSchemes(array $schemes): self
432
    {
433
        $self = clone $this;
1✔
434
        $self->schemes = $schemes;
1✔
435

436
        return $self;
1✔
437
    }
438

439
    public function getCondition(): ?string
440
    {
441
        return $this->condition;
14✔
442
    }
443

444
    public function withCondition(string $condition): self
445
    {
446
        $self = clone $this;
1✔
447
        $self->condition = $condition;
1✔
448

449
        return $self;
1✔
450
    }
451

452
    public function getController(): ?string
453
    {
454
        return $this->controller;
17✔
455
    }
456

457
    public function withController(string $controller): self
458
    {
459
        $self = clone $this;
1✔
460
        $self->controller = $controller;
1✔
461

462
        return $self;
1✔
463
    }
464

465
    public function getCacheHeaders(): ?array
466
    {
467
        return $this->cacheHeaders;
27✔
468
    }
469

470
    public function withCacheHeaders(array $cacheHeaders): self
471
    {
472
        $self = clone $this;
3✔
473
        $self->cacheHeaders = $cacheHeaders;
3✔
474

475
        return $self;
3✔
476
    }
477

478
    public function getPaginationViaCursor(): ?array
479
    {
480
        return $this->paginationViaCursor;
11✔
481
    }
482

483
    public function withPaginationViaCursor(array $paginationViaCursor): self
484
    {
485
        $self = clone $this;
2✔
486
        $self->paginationViaCursor = $paginationViaCursor;
2✔
487

488
        return $self;
2✔
489
    }
490

491
    public function getHydraContext(): ?array
492
    {
493
        return $this->hydraContext;
12✔
494
    }
495

496
    public function withHydraContext(array $hydraContext): self
497
    {
498
        $self = clone $this;
2✔
499
        $self->hydraContext = $hydraContext;
2✔
500

501
        return $self;
2✔
502
    }
503

504
    public function getOpenapiContext(): ?array
505
    {
506
        return $this->openapiContext;
12✔
507
    }
508

509
    public function withOpenapiContext(array $openapiContext): self
510
    {
511
        $self = clone $this;
1✔
512
        $self->openapiContext = $openapiContext;
1✔
513

514
        return $self;
1✔
515
    }
516

517
    public function getOpenapi(): bool|OpenApiOperation|null
518
    {
519
        return $this->openapi;
12✔
520
    }
521

522
    public function withOpenapi(bool|OpenApiOperation $openapi): self
523
    {
524
        $self = clone $this;
×
525
        $self->openapi = $openapi;
×
526

527
        return $self;
×
528
    }
529

530
    public function getExceptionToStatus(): ?array
531
    {
532
        return $this->exceptionToStatus;
24✔
533
    }
534

535
    public function withExceptionToStatus(array $exceptionToStatus): self
536
    {
537
        $self = clone $this;
11✔
538
        $self->exceptionToStatus = $exceptionToStatus;
11✔
539

540
        return $self;
11✔
541
    }
542

543
    public function getQueryParameterValidationEnabled(): ?bool
544
    {
545
        return $this->queryParameterValidationEnabled;
26✔
546
    }
547

548
    public function withQueryParameterValidationEnabled(bool $queryParameterValidationEnabled): self
549
    {
550
        $self = clone $this;
×
551
        $self->queryParameterValidationEnabled = $queryParameterValidationEnabled;
×
552

553
        return $self;
×
554
    }
555
}
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

© 2026 Coveralls, Inc