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

api-platform / core / 15775135891

20 Jun 2025 08:42AM UTC coverage: 22.065% (+0.2%) from 21.876%
15775135891

push

github

soyuka
Merge 4.1

13 of 103 new or added lines in 10 files covered. (12.62%)

868 existing lines in 35 files now uncovered.

11487 of 52060 relevant lines covered (22.06%)

21.72 hits per line

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

61.45
/src/Metadata/Metadata.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\State\OptionsInterface;
17

18
/**
19
 * @internal
20
 */
21
abstract class Metadata
22
{
23
    protected ?Parameters $parameters = null;
24

25
    /**
26
     * @param string|null                                                                       $deprecationReason       https://api-platform.com/docs/core/deprecations/#deprecating-resource-classes-operations-and-properties
27
     * @param string|\Stringable|null                                                           $security                https://api-platform.com/docs/core/security
28
     * @param string|\Stringable|null                                                           $securityPostDenormalize https://api-platform.com/docs/core/security/#executing-access-control-rules-after-denormalization
29
     * @param mixed|null                                                                        $mercure
30
     * @param mixed|null                                                                        $messenger
31
     * @param mixed|null                                                                        $input
32
     * @param mixed|null                                                                        $output
33
     * @param mixed|null                                                                        $provider
34
     * @param mixed|null                                                                        $processor
35
     * @param Parameters|array<string, Parameter>                                               $parameters
36
     * @param callable|string|array<string, \Illuminate\Contracts\Validation\Rule|array|string> $rules                   Laravel rules can be a FormRequest class, a callable or an array of rules
37
     */
38
    public function __construct(
39
        protected ?string $shortName = null,
40
        protected ?string $class = null,
41
        protected ?string $description = null,
42
        protected ?int $urlGenerationStrategy = null,
43
        protected ?string $deprecationReason = null,
44
        protected ?array $normalizationContext = null,
45
        protected ?array $denormalizationContext = null,
46
        protected ?bool $collectDenormalizationErrors = null,
47
        protected ?array $validationContext = null,
48
        protected ?array $filters = null,
49
        protected $mercure = null,
50
        protected $messenger = null,
51
        protected $input = null,
52
        protected $output = null,
53
        protected ?array $order = null,
54
        protected ?bool $fetchPartial = null,
55
        protected ?bool $forceEager = null,
56
        protected ?bool $paginationEnabled = null,
57
        protected ?string $paginationType = null,
58
        protected ?int $paginationItemsPerPage = null,
59
        protected ?int $paginationMaximumItemsPerPage = null,
60
        protected ?bool $paginationPartial = null,
61
        protected ?bool $paginationClientEnabled = null,
62
        protected ?bool $paginationClientItemsPerPage = null,
63
        protected ?bool $paginationClientPartial = null,
64
        protected ?bool $paginationFetchJoinCollection = null,
65
        protected ?bool $paginationUseOutputWalkers = null,
66
        protected string|\Stringable|null $security = null,
67
        protected ?string $securityMessage = null,
68
        protected string|\Stringable|null $securityPostDenormalize = null,
69
        protected ?string $securityPostDenormalizeMessage = null,
70
        protected string|\Stringable|null $securityPostValidation = null,
71
        protected ?string $securityPostValidationMessage = null,
72
        protected $provider = null,
73
        protected $processor = null,
74
        protected ?OptionsInterface $stateOptions = null,
75
        /*
76
         * @experimental
77
         */
78
        array|Parameters|null $parameters = null,
79
        protected mixed $rules = null,
80
        protected ?string $policy = null,
81
        protected array|string|null $middleware = null,
82
        protected ?bool $queryParameterValidationEnabled = null,
83
        protected ?bool $strictQueryParameterValidation = null,
84
        protected ?bool $hideHydraOperation = null,
85
        protected array $extraProperties = [],
86
    ) {
87
        if (\is_array($parameters) && $parameters) {
712✔
88
            $parameters = new Parameters($parameters);
28✔
89
        }
90

91
        $this->parameters = $parameters;
712✔
92
    }
93

94
    public function getShortName(): ?string
95
    {
96
        return $this->shortName;
568✔
97
    }
98

99
    public function withShortName(string $shortName): static
100
    {
101
        $self = clone $this;
166✔
102
        $self->shortName = $shortName;
166✔
103

104
        return $self;
166✔
105
    }
106

107
    public function getClass(): ?string
108
    {
109
        return $this->class;
624✔
110
    }
111

112
    public function withClass(string $class): static
113
    {
114
        $self = clone $this;
480✔
115
        $self->class = $class;
480✔
116

117
        return $self;
480✔
118
    }
119

120
    public function getDescription(): ?string
121
    {
122
        return $this->description;
210✔
123
    }
124

125
    public function withDescription(?string $description = null): static
126
    {
127
        $self = clone $this;
88✔
128
        $self->description = $description;
88✔
129

130
        return $self;
88✔
131
    }
132

133
    public function getUrlGenerationStrategy(): ?int
134
    {
135
        return $this->urlGenerationStrategy;
543✔
136
    }
137

138
    public function withUrlGenerationStrategy(int $urlGenerationStrategy): static
139
    {
UNCOV
140
        $self = clone $this;
×
141
        $self->urlGenerationStrategy = $urlGenerationStrategy;
×
142

UNCOV
143
        return $self;
×
144
    }
145

146
    public function getDeprecationReason(): ?string
147
    {
148
        return $this->deprecationReason;
210✔
149
    }
150

151
    public function withDeprecationReason($deprecationReason): static
152
    {
UNCOV
153
        $self = clone $this;
×
154
        $self->deprecationReason = $deprecationReason;
×
155

UNCOV
156
        return $self;
×
157
    }
158

159
    public function getNormalizationContext(): ?array
160
    {
161
        return $this->normalizationContext;
602✔
162
    }
163

164
    public function withNormalizationContext(array $normalizationContext): static
165
    {
166
        $self = clone $this;
168✔
167
        $self->normalizationContext = $normalizationContext;
168✔
168

169
        return $self;
168✔
170
    }
171

172
    public function getDenormalizationContext(): ?array
173
    {
174
        return $this->denormalizationContext;
595✔
175
    }
176

177
    public function withDenormalizationContext(array $denormalizationContext): static
178
    {
179
        $self = clone $this;
21✔
180
        $self->denormalizationContext = $denormalizationContext;
21✔
181

182
        return $self;
21✔
183
    }
184

185
    public function getCollectDenormalizationErrors(): ?bool
186
    {
187
        return $this->collectDenormalizationErrors;
514✔
188
    }
189

190
    public function withCollectDenormalizationErrors(?bool $collectDenormalizationErrors = null): static
191
    {
192
        $self = clone $this;
2✔
193
        $self->collectDenormalizationErrors = $collectDenormalizationErrors;
2✔
194

195
        return $self;
2✔
196
    }
197

198
    public function getValidationContext(): ?array
199
    {
200
        return $this->validationContext;
198✔
201
    }
202

203
    public function withValidationContext(array $validationContext): static
204
    {
UNCOV
205
        $self = clone $this;
×
206
        $self->validationContext = $validationContext;
×
207

UNCOV
208
        return $self;
×
209
    }
210

211
    /**
212
     * @return string[]|null
213
     */
214
    public function getFilters(): ?array
215
    {
216
        return $this->filters;
554✔
217
    }
218

219
    public function withFilters(array $filters): static
220
    {
221
        $self = clone $this;
100✔
222
        $self->filters = $filters;
100✔
223

224
        return $self;
100✔
225
    }
226

227
    /**
228
     * @return array|bool|mixed|null
229
     */
230
    public function getMercure()
231
    {
232
        return $this->mercure;
533✔
233
    }
234

235
    public function withMercure($mercure): static
236
    {
237
        $self = clone $this;
2✔
238
        $self->mercure = $mercure;
2✔
239

240
        return $self;
2✔
241
    }
242

243
    public function getMessenger()
244
    {
245
        return $this->messenger;
102✔
246
    }
247

248
    public function withMessenger($messenger): static
249
    {
UNCOV
250
        $self = clone $this;
×
UNCOV
251
        $self->messenger = $messenger;
×
252

UNCOV
253
        return $self;
×
254
    }
255

256
    public function getInput()
257
    {
258
        return $this->input;
560✔
259
    }
260

261
    public function withInput($input): static
262
    {
263
        $self = clone $this;
124✔
264
        $self->input = $input;
124✔
265

266
        return $self;
124✔
267
    }
268

269
    public function getOutput()
270
    {
271
        return $this->output;
586✔
272
    }
273

274
    public function withOutput($output): static
275
    {
276
        $self = clone $this;
96✔
277
        $self->output = $output;
96✔
278

279
        return $self;
96✔
280
    }
281

282
    public function getOrder(): ?array
283
    {
284
        return $this->order;
274✔
285
    }
286

287
    public function withOrder(array $order): static
288
    {
UNCOV
289
        $self = clone $this;
×
UNCOV
290
        $self->order = $order;
×
291

UNCOV
292
        return $self;
×
293
    }
294

295
    public function getFetchPartial(): ?bool
296
    {
297
        return $this->fetchPartial;
314✔
298
    }
299

300
    public function withFetchPartial(bool $fetchPartial): static
301
    {
UNCOV
302
        $self = clone $this;
×
UNCOV
303
        $self->fetchPartial = $fetchPartial;
×
304

UNCOV
305
        return $self;
×
306
    }
307

308
    public function getForceEager(): ?bool
309
    {
310
        return $this->forceEager;
314✔
311
    }
312

313
    public function withForceEager(bool $forceEager): static
314
    {
UNCOV
315
        $self = clone $this;
×
UNCOV
316
        $self->forceEager = $forceEager;
×
317

UNCOV
318
        return $self;
×
319
    }
320

321
    public function getPaginationEnabled(): ?bool
322
    {
323
        return $this->paginationEnabled;
320✔
324
    }
325

326
    public function withPaginationEnabled(bool $paginationEnabled): static
327
    {
UNCOV
328
        $self = clone $this;
×
UNCOV
329
        $self->paginationEnabled = $paginationEnabled;
×
330

UNCOV
331
        return $self;
×
332
    }
333

334
    public function getPaginationType(): ?string
335
    {
336
        return $this->paginationType;
112✔
337
    }
338

339
    public function withPaginationType(string $paginationType): static
340
    {
UNCOV
341
        $self = clone $this;
×
UNCOV
342
        $self->paginationType = $paginationType;
×
343

UNCOV
344
        return $self;
×
345
    }
346

347
    public function getPaginationItemsPerPage(): ?int
348
    {
349
        return $this->paginationItemsPerPage;
312✔
350
    }
351

352
    public function withPaginationItemsPerPage(int $paginationItemsPerPage): static
353
    {
354
        $self = clone $this;
96✔
355
        $self->paginationItemsPerPage = $paginationItemsPerPage;
96✔
356

357
        return $self;
96✔
358
    }
359

360
    public function getPaginationMaximumItemsPerPage(): ?int
361
    {
362
        return $this->paginationMaximumItemsPerPage;
312✔
363
    }
364

365
    public function withPaginationMaximumItemsPerPage(int $paginationMaximumItemsPerPage): static
366
    {
UNCOV
367
        $self = clone $this;
×
UNCOV
368
        $self->paginationMaximumItemsPerPage = $paginationMaximumItemsPerPage;
×
369

UNCOV
370
        return $self;
×
371
    }
372

373
    public function getPaginationPartial(): ?bool
374
    {
375
        return $this->paginationPartial;
294✔
376
    }
377

378
    public function withPaginationPartial(bool $paginationPartial): static
379
    {
UNCOV
380
        $self = clone $this;
×
UNCOV
381
        $self->paginationPartial = $paginationPartial;
×
382

UNCOV
383
        return $self;
×
384
    }
385

386
    public function getPaginationClientEnabled(): ?bool
387
    {
388
        return $this->paginationClientEnabled;
308✔
389
    }
390

391
    public function withPaginationClientEnabled(bool $paginationClientEnabled): static
392
    {
393
        $self = clone $this;
96✔
394
        $self->paginationClientEnabled = $paginationClientEnabled;
96✔
395

396
        return $self;
96✔
397
    }
398

399
    public function getPaginationClientItemsPerPage(): ?bool
400
    {
401
        return $this->paginationClientItemsPerPage;
312✔
402
    }
403

404
    public function withPaginationClientItemsPerPage(bool $paginationClientItemsPerPage): static
405
    {
406
        $self = clone $this;
96✔
407
        $self->paginationClientItemsPerPage = $paginationClientItemsPerPage;
96✔
408

409
        return $self;
96✔
410
    }
411

412
    public function getPaginationClientPartial(): ?bool
413
    {
414
        return $this->paginationClientPartial;
294✔
415
    }
416

417
    public function withPaginationClientPartial(bool $paginationClientPartial): static
418
    {
419
        $self = clone $this;
96✔
420
        $self->paginationClientPartial = $paginationClientPartial;
96✔
421

422
        return $self;
96✔
423
    }
424

425
    public function getPaginationFetchJoinCollection(): ?bool
426
    {
427
        return $this->paginationFetchJoinCollection;
294✔
428
    }
429

430
    public function withPaginationFetchJoinCollection(bool $paginationFetchJoinCollection): static
431
    {
UNCOV
432
        $self = clone $this;
×
UNCOV
433
        $self->paginationFetchJoinCollection = $paginationFetchJoinCollection;
×
434

UNCOV
435
        return $self;
×
436
    }
437

438
    public function getPaginationUseOutputWalkers(): ?bool
439
    {
440
        return $this->paginationUseOutputWalkers;
294✔
441
    }
442

443
    public function withPaginationUseOutputWalkers(bool $paginationUseOutputWalkers): static
444
    {
UNCOV
445
        $self = clone $this;
×
UNCOV
446
        $self->paginationUseOutputWalkers = $paginationUseOutputWalkers;
×
447

UNCOV
448
        return $self;
×
449
    }
450

451
    public function getSecurity(): ?string
452
    {
453
        return $this->security instanceof \Stringable ? (string) $this->security : $this->security;
547✔
454
    }
455

456
    public function withSecurity($security): static
457
    {
458
        $self = clone $this;
2✔
459
        $self->security = $security;
2✔
460

461
        return $self;
2✔
462
    }
463

464
    public function getSecurityMessage(): ?string
465
    {
466
        return $this->securityMessage;
534✔
467
    }
468

469
    public function withSecurityMessage(string $securityMessage): static
470
    {
UNCOV
471
        $self = clone $this;
×
UNCOV
472
        $self->securityMessage = $securityMessage;
×
473

UNCOV
474
        return $self;
×
475
    }
476

477
    public function getSecurityPostDenormalize(): ?string
478
    {
479
        return $this->securityPostDenormalize instanceof \Stringable ? (string) $this->securityPostDenormalize : $this->securityPostDenormalize;
339✔
480
    }
481

482
    public function withSecurityPostDenormalize($securityPostDenormalize): static
483
    {
UNCOV
484
        $self = clone $this;
×
UNCOV
485
        $self->securityPostDenormalize = $securityPostDenormalize;
×
486

UNCOV
487
        return $self;
×
488
    }
489

490
    public function getSecurityPostDenormalizeMessage(): ?string
491
    {
492
        return $this->securityPostDenormalizeMessage;
339✔
493
    }
494

495
    public function withSecurityPostDenormalizeMessage(string $securityPostDenormalizeMessage): static
496
    {
UNCOV
497
        $self = clone $this;
×
UNCOV
498
        $self->securityPostDenormalizeMessage = $securityPostDenormalizeMessage;
×
499

UNCOV
500
        return $self;
×
501
    }
502

503
    public function getSecurityPostValidation(): ?string
504
    {
505
        return $this->securityPostValidation instanceof \Stringable ? (string) $this->securityPostValidation : $this->securityPostValidation;
524✔
506
    }
507

508
    public function withSecurityPostValidation(string|\Stringable|null $securityPostValidation = null): static
509
    {
UNCOV
510
        $self = clone $this;
×
UNCOV
511
        $self->securityPostValidation = $securityPostValidation;
×
512

UNCOV
513
        return $self;
×
514
    }
515

516
    public function getSecurityPostValidationMessage(): ?string
517
    {
518
        return $this->securityPostValidationMessage;
524✔
519
    }
520

521
    public function withSecurityPostValidationMessage(?string $securityPostValidationMessage = null): static
522
    {
UNCOV
523
        $self = clone $this;
×
UNCOV
524
        $self->securityPostValidationMessage = $securityPostValidationMessage;
×
525

UNCOV
526
        return $self;
×
527
    }
528

529
    public function getProcessor(): callable|string|null
530
    {
531
        return $this->processor;
134✔
532
    }
533

534
    public function withProcessor(callable|string|null $processor): static
535
    {
536
        $self = clone $this;
52✔
537
        $self->processor = $processor;
52✔
538

539
        return $self;
52✔
540
    }
541

542
    public function getProvider(): callable|string|null
543
    {
544
        return $this->provider;
528✔
545
    }
546

547
    public function withProvider(callable|string|null $provider): static
548
    {
549
        $self = clone $this;
60✔
550
        $self->provider = $provider;
60✔
551

552
        return $self;
60✔
553
    }
554

555
    public function getStateOptions(): ?OptionsInterface
556
    {
557
        return $this->stateOptions;
532✔
558
    }
559

560
    public function withStateOptions(?OptionsInterface $stateOptions): static
561
    {
562
        $self = clone $this;
48✔
563
        $self->stateOptions = $stateOptions;
48✔
564

565
        return $self;
48✔
566
    }
567

568
    /**
569
     * @return string|callable|array<string, \Illuminate\Contracts\Validation\Rule|array|string>
570
     */
571
    public function getRules(): mixed
572
    {
573
        return $this->rules;
102✔
574
    }
575

576
    /**
577
     * @param string|callable|array<string, \Illuminate\Contracts\Validation\Rule|array|string> $rules
578
     */
579
    public function withRules(mixed $rules): static
580
    {
UNCOV
581
        $self = clone $this;
×
UNCOV
582
        $self->rules = $rules;
×
583

UNCOV
584
        return $self;
×
585
    }
586

587
    public function getParameters(): ?Parameters
588
    {
589
        return $this->parameters;
548✔
590
    }
591

592
    public function withParameters(array|Parameters $parameters): static
593
    {
594
        $self = clone $this;
286✔
595
        $self->parameters = \is_array($parameters) ? new Parameters($parameters) : $parameters;
286✔
596

597
        return $self;
286✔
598
    }
599

600
    public function getQueryParameterValidationEnabled(): ?bool
601
    {
602
        return $this->queryParameterValidationEnabled;
504✔
603
    }
604

605
    public function withQueryParameterValidationEnabled(bool $queryParameterValidationEnabled): static
606
    {
UNCOV
607
        $self = clone $this;
×
UNCOV
608
        $self->queryParameterValidationEnabled = $queryParameterValidationEnabled;
×
609

UNCOV
610
        return $self;
×
611
    }
612

613
    public function getPolicy(): ?string
614
    {
615
        return $this->policy;
102✔
616
    }
617

618
    public function withPolicy(string $policy): static
619
    {
UNCOV
620
        $self = clone $this;
×
UNCOV
621
        $self->policy = $policy;
×
622

UNCOV
623
        return $self;
×
624
    }
625

626
    public function getMiddleware(): mixed
627
    {
628
        return $this->middleware;
102✔
629
    }
630

631
    public function withMiddleware(string|array $middleware): static
632
    {
UNCOV
633
        $self = clone $this;
×
UNCOV
634
        $self->middleware = $middleware;
×
635

UNCOV
636
        return $self;
×
637
    }
638

639
    public function getExtraProperties(): ?array
640
    {
641
        return $this->extraProperties;
308✔
642
    }
643

644
    public function withExtraProperties(array $extraProperties = []): static
645
    {
646
        $self = clone $this;
102✔
647
        $self->extraProperties = $extraProperties;
102✔
648

649
        return $self;
102✔
650
    }
651

652
    public function getStrictQueryParameterValidation(): ?bool
653
    {
654
        return $this->strictQueryParameterValidation;
504✔
655
    }
656

657
    public function withStrictQueryParameterValidation(bool $strictQueryParameterValidation): static
658
    {
UNCOV
659
        $self = clone $this;
×
UNCOV
660
        $self->strictQueryParameterValidation = $strictQueryParameterValidation;
×
661

UNCOV
662
        return $self;
×
663
    }
664

665
    public function getHideHydraOperation(): ?bool
666
    {
667
        return $this->hideHydraOperation;
110✔
668
    }
669

670
    public function withHideHydraOperation(bool $hideHydraOperation): static
671
    {
672
        $self = clone $this;
2✔
673
        $self->hideHydraOperation = $hideHydraOperation;
2✔
674

675
        return $self;
2✔
676
    }
677
}
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