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

api-platform / core / 16050929464

03 Jul 2025 12:51PM UTC coverage: 22.065% (+0.2%) from 21.821%
16050929464

push

github

soyuka
chore: todo improvement

11516 of 52192 relevant lines covered (22.06%)

22.08 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) {
719✔
88
            $parameters = new Parameters($parameters);
28✔
89
        }
90

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

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

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

104
        return $self;
170✔
105
    }
106

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

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

117
        return $self;
487✔
118
    }
119

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

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

130
        return $self;
90✔
131
    }
132

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

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

143
        return $self;
×
144
    }
145

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

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

156
        return $self;
×
157
    }
158

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

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

169
        return $self;
174✔
170
    }
171

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

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

182
        return $self;
25✔
183
    }
184

185
    public function getCollectDenormalizationErrors(): ?bool
186
    {
187
        return $this->collectDenormalizationErrors;
522✔
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;
204✔
201
    }
202

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

208
        return $self;
×
209
    }
210

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

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

224
        return $self;
104✔
225
    }
226

227
    public function getMercure(): mixed
228
    {
229
        return $this->mercure;
541✔
230
    }
231

232
    public function withMercure(mixed $mercure): static
233
    {
234
        $self = clone $this;
2✔
235
        $self->mercure = $mercure;
2✔
236

237
        return $self;
2✔
238
    }
239

240
    public function getMessenger(): mixed
241
    {
242
        return $this->messenger;
106✔
243
    }
244

245
    public function withMessenger(mixed $messenger): static
246
    {
247
        $self = clone $this;
×
248
        $self->messenger = $messenger;
×
249

250
        return $self;
×
251
    }
252

253
    public function getInput(): mixed
254
    {
255
        return $this->input;
568✔
256
    }
257

258
    public function withInput(mixed $input): static
259
    {
260
        $self = clone $this;
128✔
261
        $self->input = $input;
128✔
262

263
        return $self;
128✔
264
    }
265

266
    public function getOutput(): mixed
267
    {
268
        return $this->output;
594✔
269
    }
270

271
    public function withOutput(mixed $output): static
272
    {
273
        $self = clone $this;
100✔
274
        $self->output = $output;
100✔
275

276
        return $self;
100✔
277
    }
278

279
    public function getOrder(): ?array
280
    {
281
        return $this->order;
278✔
282
    }
283

284
    public function withOrder(array $order): static
285
    {
286
        $self = clone $this;
×
287
        $self->order = $order;
×
288

289
        return $self;
×
290
    }
291

292
    public function getFetchPartial(): ?bool
293
    {
294
        return $this->fetchPartial;
318✔
295
    }
296

297
    public function withFetchPartial(bool $fetchPartial): static
298
    {
299
        $self = clone $this;
×
300
        $self->fetchPartial = $fetchPartial;
×
301

302
        return $self;
×
303
    }
304

305
    public function getForceEager(): ?bool
306
    {
307
        return $this->forceEager;
318✔
308
    }
309

310
    public function withForceEager(bool $forceEager): static
311
    {
312
        $self = clone $this;
×
313
        $self->forceEager = $forceEager;
×
314

315
        return $self;
×
316
    }
317

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

323
    public function withPaginationEnabled(bool $paginationEnabled): static
324
    {
325
        $self = clone $this;
×
326
        $self->paginationEnabled = $paginationEnabled;
×
327

328
        return $self;
×
329
    }
330

331
    public function getPaginationType(): ?string
332
    {
333
        return $this->paginationType;
116✔
334
    }
335

336
    public function withPaginationType(string $paginationType): static
337
    {
338
        $self = clone $this;
×
339
        $self->paginationType = $paginationType;
×
340

341
        return $self;
×
342
    }
343

344
    public function getPaginationItemsPerPage(): ?int
345
    {
346
        return $this->paginationItemsPerPage;
316✔
347
    }
348

349
    public function withPaginationItemsPerPage(int $paginationItemsPerPage): static
350
    {
351
        $self = clone $this;
100✔
352
        $self->paginationItemsPerPage = $paginationItemsPerPage;
100✔
353

354
        return $self;
100✔
355
    }
356

357
    public function getPaginationMaximumItemsPerPage(): ?int
358
    {
359
        return $this->paginationMaximumItemsPerPage;
316✔
360
    }
361

362
    public function withPaginationMaximumItemsPerPage(int $paginationMaximumItemsPerPage): static
363
    {
364
        $self = clone $this;
×
365
        $self->paginationMaximumItemsPerPage = $paginationMaximumItemsPerPage;
×
366

367
        return $self;
×
368
    }
369

370
    public function getPaginationPartial(): ?bool
371
    {
372
        return $this->paginationPartial;
298✔
373
    }
374

375
    public function withPaginationPartial(bool $paginationPartial): static
376
    {
377
        $self = clone $this;
×
378
        $self->paginationPartial = $paginationPartial;
×
379

380
        return $self;
×
381
    }
382

383
    public function getPaginationClientEnabled(): ?bool
384
    {
385
        return $this->paginationClientEnabled;
312✔
386
    }
387

388
    public function withPaginationClientEnabled(bool $paginationClientEnabled): static
389
    {
390
        $self = clone $this;
100✔
391
        $self->paginationClientEnabled = $paginationClientEnabled;
100✔
392

393
        return $self;
100✔
394
    }
395

396
    public function getPaginationClientItemsPerPage(): ?bool
397
    {
398
        return $this->paginationClientItemsPerPage;
316✔
399
    }
400

401
    public function withPaginationClientItemsPerPage(bool $paginationClientItemsPerPage): static
402
    {
403
        $self = clone $this;
100✔
404
        $self->paginationClientItemsPerPage = $paginationClientItemsPerPage;
100✔
405

406
        return $self;
100✔
407
    }
408

409
    public function getPaginationClientPartial(): ?bool
410
    {
411
        return $this->paginationClientPartial;
298✔
412
    }
413

414
    public function withPaginationClientPartial(bool $paginationClientPartial): static
415
    {
416
        $self = clone $this;
100✔
417
        $self->paginationClientPartial = $paginationClientPartial;
100✔
418

419
        return $self;
100✔
420
    }
421

422
    public function getPaginationFetchJoinCollection(): ?bool
423
    {
424
        return $this->paginationFetchJoinCollection;
298✔
425
    }
426

427
    public function withPaginationFetchJoinCollection(bool $paginationFetchJoinCollection): static
428
    {
429
        $self = clone $this;
×
430
        $self->paginationFetchJoinCollection = $paginationFetchJoinCollection;
×
431

432
        return $self;
×
433
    }
434

435
    public function getPaginationUseOutputWalkers(): ?bool
436
    {
437
        return $this->paginationUseOutputWalkers;
298✔
438
    }
439

440
    public function withPaginationUseOutputWalkers(bool $paginationUseOutputWalkers): static
441
    {
442
        $self = clone $this;
×
443
        $self->paginationUseOutputWalkers = $paginationUseOutputWalkers;
×
444

445
        return $self;
×
446
    }
447

448
    public function getSecurity(): ?string
449
    {
450
        return $this->security instanceof \Stringable ? (string) $this->security : $this->security;
555✔
451
    }
452

453
    public function withSecurity($security): static
454
    {
455
        $self = clone $this;
2✔
456
        $self->security = $security;
2✔
457

458
        return $self;
2✔
459
    }
460

461
    public function getSecurityMessage(): ?string
462
    {
463
        return $this->securityMessage;
542✔
464
    }
465

466
    public function withSecurityMessage(string $securityMessage): static
467
    {
468
        $self = clone $this;
×
469
        $self->securityMessage = $securityMessage;
×
470

471
        return $self;
×
472
    }
473

474
    public function getSecurityPostDenormalize(): ?string
475
    {
476
        return $this->securityPostDenormalize instanceof \Stringable ? (string) $this->securityPostDenormalize : $this->securityPostDenormalize;
346✔
477
    }
478

479
    public function withSecurityPostDenormalize($securityPostDenormalize): static
480
    {
481
        $self = clone $this;
×
482
        $self->securityPostDenormalize = $securityPostDenormalize;
×
483

484
        return $self;
×
485
    }
486

487
    public function getSecurityPostDenormalizeMessage(): ?string
488
    {
489
        return $this->securityPostDenormalizeMessage;
346✔
490
    }
491

492
    public function withSecurityPostDenormalizeMessage(string $securityPostDenormalizeMessage): static
493
    {
494
        $self = clone $this;
×
495
        $self->securityPostDenormalizeMessage = $securityPostDenormalizeMessage;
×
496

497
        return $self;
×
498
    }
499

500
    public function getSecurityPostValidation(): ?string
501
    {
502
        return $this->securityPostValidation instanceof \Stringable ? (string) $this->securityPostValidation : $this->securityPostValidation;
532✔
503
    }
504

505
    public function withSecurityPostValidation(string|\Stringable|null $securityPostValidation = null): static
506
    {
507
        $self = clone $this;
×
508
        $self->securityPostValidation = $securityPostValidation;
×
509

510
        return $self;
×
511
    }
512

513
    public function getSecurityPostValidationMessage(): ?string
514
    {
515
        return $this->securityPostValidationMessage;
532✔
516
    }
517

518
    public function withSecurityPostValidationMessage(?string $securityPostValidationMessage = null): static
519
    {
520
        $self = clone $this;
×
521
        $self->securityPostValidationMessage = $securityPostValidationMessage;
×
522

523
        return $self;
×
524
    }
525

526
    public function getProcessor(): callable|string|null
527
    {
528
        return $this->processor;
140✔
529
    }
530

531
    public function withProcessor(callable|string|null $processor): static
532
    {
533
        $self = clone $this;
56✔
534
        $self->processor = $processor;
56✔
535

536
        return $self;
56✔
537
    }
538

539
    public function getProvider(): callable|string|null
540
    {
541
        return $this->provider;
534✔
542
    }
543

544
    public function withProvider(callable|string|null $provider): static
545
    {
546
        $self = clone $this;
64✔
547
        $self->provider = $provider;
64✔
548

549
        return $self;
64✔
550
    }
551

552
    public function getStateOptions(): ?OptionsInterface
553
    {
554
        return $this->stateOptions;
542✔
555
    }
556

557
    public function withStateOptions(?OptionsInterface $stateOptions): static
558
    {
559
        $self = clone $this;
52✔
560
        $self->stateOptions = $stateOptions;
52✔
561

562
        return $self;
52✔
563
    }
564

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

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

581
        return $self;
×
582
    }
583

584
    public function getParameters(): ?Parameters
585
    {
586
        return $this->parameters;
556✔
587
    }
588

589
    public function withParameters(array|Parameters $parameters): static
590
    {
591
        $self = clone $this;
288✔
592
        $self->parameters = \is_array($parameters) ? new Parameters($parameters) : $parameters;
288✔
593

594
        return $self;
288✔
595
    }
596

597
    public function getQueryParameterValidationEnabled(): ?bool
598
    {
599
        return $this->queryParameterValidationEnabled;
512✔
600
    }
601

602
    public function withQueryParameterValidationEnabled(bool $queryParameterValidationEnabled): static
603
    {
604
        $self = clone $this;
×
605
        $self->queryParameterValidationEnabled = $queryParameterValidationEnabled;
×
606

607
        return $self;
×
608
    }
609

610
    public function getPolicy(): ?string
611
    {
612
        return $this->policy;
106✔
613
    }
614

615
    public function withPolicy(string $policy): static
616
    {
617
        $self = clone $this;
×
618
        $self->policy = $policy;
×
619

620
        return $self;
×
621
    }
622

623
    public function getMiddleware(): mixed
624
    {
625
        return $this->middleware;
106✔
626
    }
627

628
    public function withMiddleware(string|array $middleware): static
629
    {
630
        $self = clone $this;
×
631
        $self->middleware = $middleware;
×
632

633
        return $self;
×
634
    }
635

636
    public function getExtraProperties(): ?array
637
    {
638
        return $this->extraProperties;
316✔
639
    }
640

641
    public function withExtraProperties(array $extraProperties = []): static
642
    {
643
        $self = clone $this;
106✔
644
        $self->extraProperties = $extraProperties;
106✔
645

646
        return $self;
106✔
647
    }
648

649
    public function getStrictQueryParameterValidation(): ?bool
650
    {
651
        return $this->strictQueryParameterValidation;
512✔
652
    }
653

654
    public function withStrictQueryParameterValidation(bool $strictQueryParameterValidation): static
655
    {
656
        $self = clone $this;
×
657
        $self->strictQueryParameterValidation = $strictQueryParameterValidation;
×
658

659
        return $self;
×
660
    }
661

662
    public function getHideHydraOperation(): ?bool
663
    {
664
        return $this->hideHydraOperation;
114✔
665
    }
666

667
    public function withHideHydraOperation(bool $hideHydraOperation): static
668
    {
669
        $self = clone $this;
2✔
670
        $self->hideHydraOperation = $hideHydraOperation;
2✔
671

672
        return $self;
2✔
673
    }
674
}
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