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

api-platform / core / 15186284751

22 May 2025 12:14PM UTC coverage: 27.348%. Remained the same
15186284751

push

github

soyuka
docs: changelog 4.1.10

13482 of 49298 relevant lines covered (27.35%)

74.57 hits per line

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

68.85
/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 ?bool $elasticsearch = null,
50
        protected $mercure = null,
51
        protected $messenger = null,
52
        protected $input = null,
53
        protected $output = null,
54
        protected ?array $order = null,
55
        protected ?bool $fetchPartial = null,
56
        protected ?bool $forceEager = null,
57
        protected ?bool $paginationEnabled = null,
58
        protected ?string $paginationType = null,
59
        protected ?int $paginationItemsPerPage = null,
60
        protected ?int $paginationMaximumItemsPerPage = null,
61
        protected ?bool $paginationPartial = null,
62
        protected ?bool $paginationClientEnabled = null,
63
        protected ?bool $paginationClientItemsPerPage = null,
64
        protected ?bool $paginationClientPartial = null,
65
        protected ?bool $paginationFetchJoinCollection = null,
66
        protected ?bool $paginationUseOutputWalkers = null,
67
        protected string|\Stringable|null $security = null,
68
        protected ?string $securityMessage = null,
69
        protected string|\Stringable|null $securityPostDenormalize = null,
70
        protected ?string $securityPostDenormalizeMessage = null,
71
        protected string|\Stringable|null $securityPostValidation = null,
72
        protected ?string $securityPostValidationMessage = null,
73
        protected $provider = null,
74
        protected $processor = null,
75
        protected ?OptionsInterface $stateOptions = null,
76
        /*
77
         * @experimental
78
         */
79
        array|Parameters|null $parameters = null,
80
        protected mixed $rules = null,
81
        protected ?string $policy = null,
82
        protected array|string|null $middleware = null,
83
        protected ?bool $queryParameterValidationEnabled = null,
84
        protected ?bool $strictQueryParameterValidation = null,
85
        protected ?bool $hideHydraOperation = null,
86
        protected array $extraProperties = [],
87
    ) {
88
        if (\is_array($parameters) && $parameters) {
2,113✔
89
            $parameters = new Parameters($parameters);
31✔
90
        }
91

92
        $this->parameters = $parameters;
2,113✔
93
    }
94

95
    public function getShortName(): ?string
96
    {
97
        return $this->shortName;
1,889✔
98
    }
99

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

105
        return $self;
215✔
106
    }
107

108
    public function getClass(): ?string
109
    {
110
        return $this->class;
2,130✔
111
    }
112

113
    public function withClass(string $class): static
114
    {
115
        $self = clone $this;
1,782✔
116
        $self->class = $class;
1,782✔
117

118
        return $self;
1,782✔
119
    }
120

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

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

131
        return $self;
161✔
132
    }
133

134
    public function getUrlGenerationStrategy(): ?int
135
    {
136
        return $this->urlGenerationStrategy;
1,965✔
137
    }
138

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

144
        return $self;
2✔
145
    }
146

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

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

157
        return $self;
2✔
158
    }
159

160
    public function getNormalizationContext(): ?array
161
    {
162
        return $this->normalizationContext;
2,111✔
163
    }
164

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

170
        return $self;
359✔
171
    }
172

173
    public function getDenormalizationContext(): ?array
174
    {
175
        return $this->denormalizationContext;
1,641✔
176
    }
177

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

183
        return $self;
7✔
184
    }
185

186
    public function getCollectDenormalizationErrors(): ?bool
187
    {
188
        return $this->collectDenormalizationErrors;
1,761✔
189
    }
190

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

196
        return $self;
1✔
197
    }
198

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

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

209
        return $self;
×
210
    }
211

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

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

225
        return $self;
138✔
226
    }
227

228
    /**
229
     * @deprecated this will be removed in v4
230
     */
231
    public function getElasticsearch(): ?bool
232
    {
233
        return $this->elasticsearch;
140✔
234
    }
235

236
    /**
237
     * @deprecated this will be removed in v4
238
     */
239
    public function withElasticsearch(bool $elasticsearch): static
240
    {
241
        $self = clone $this;
×
242
        $self->elasticsearch = $elasticsearch;
×
243

244
        return $self;
×
245
    }
246

247
    /**
248
     * @return array|bool|mixed|null
249
     */
250
    public function getMercure()
251
    {
252
        return $this->mercure;
2,052✔
253
    }
254

255
    public function withMercure($mercure): static
256
    {
257
        $self = clone $this;
4✔
258
        $self->mercure = $mercure;
4✔
259

260
        return $self;
4✔
261
    }
262

263
    public function getMessenger()
264
    {
265
        return $this->messenger;
140✔
266
    }
267

268
    public function withMessenger($messenger): static
269
    {
270
        $self = clone $this;
×
271
        $self->messenger = $messenger;
×
272

273
        return $self;
×
274
    }
275

276
    public function getInput()
277
    {
278
        return $this->input;
2,080✔
279
    }
280

281
    public function withInput($input): static
282
    {
283
        $self = clone $this;
162✔
284
        $self->input = $input;
162✔
285

286
        return $self;
162✔
287
    }
288

289
    public function getOutput()
290
    {
291
        return $this->output;
2,100✔
292
    }
293

294
    public function withOutput($output): static
295
    {
296
        $self = clone $this;
134✔
297
        $self->output = $output;
134✔
298

299
        return $self;
134✔
300
    }
301

302
    public function getOrder(): ?array
303
    {
304
        return $this->order;
810✔
305
    }
306

307
    public function withOrder(array $order): static
308
    {
309
        $self = clone $this;
2✔
310
        $self->order = $order;
2✔
311

312
        return $self;
2✔
313
    }
314

315
    public function getFetchPartial(): ?bool
316
    {
317
        return $this->fetchPartial;
863✔
318
    }
319

320
    public function withFetchPartial(bool $fetchPartial): static
321
    {
322
        $self = clone $this;
×
323
        $self->fetchPartial = $fetchPartial;
×
324

325
        return $self;
×
326
    }
327

328
    public function getForceEager(): ?bool
329
    {
330
        return $this->forceEager;
863✔
331
    }
332

333
    public function withForceEager(bool $forceEager): static
334
    {
335
        $self = clone $this;
2✔
336
        $self->forceEager = $forceEager;
2✔
337

338
        return $self;
2✔
339
    }
340

341
    public function getPaginationEnabled(): ?bool
342
    {
343
        return $this->paginationEnabled;
1,090✔
344
    }
345

346
    public function withPaginationEnabled(bool $paginationEnabled): static
347
    {
348
        $self = clone $this;
×
349
        $self->paginationEnabled = $paginationEnabled;
×
350

351
        return $self;
×
352
    }
353

354
    public function getPaginationType(): ?string
355
    {
356
        return $this->paginationType;
425✔
357
    }
358

359
    public function withPaginationType(string $paginationType): static
360
    {
361
        $self = clone $this;
×
362
        $self->paginationType = $paginationType;
×
363

364
        return $self;
×
365
    }
366

367
    public function getPaginationItemsPerPage(): ?int
368
    {
369
        return $this->paginationItemsPerPage;
897✔
370
    }
371

372
    public function withPaginationItemsPerPage(int $paginationItemsPerPage): static
373
    {
374
        $self = clone $this;
131✔
375
        $self->paginationItemsPerPage = $paginationItemsPerPage;
131✔
376

377
        return $self;
131✔
378
    }
379

380
    public function getPaginationMaximumItemsPerPage(): ?int
381
    {
382
        return $this->paginationMaximumItemsPerPage;
897✔
383
    }
384

385
    public function withPaginationMaximumItemsPerPage(int $paginationMaximumItemsPerPage): static
386
    {
387
        $self = clone $this;
×
388
        $self->paginationMaximumItemsPerPage = $paginationMaximumItemsPerPage;
×
389

390
        return $self;
×
391
    }
392

393
    public function getPaginationPartial(): ?bool
394
    {
395
        return $this->paginationPartial;
605✔
396
    }
397

398
    public function withPaginationPartial(bool $paginationPartial): static
399
    {
400
        $self = clone $this;
2✔
401
        $self->paginationPartial = $paginationPartial;
2✔
402

403
        return $self;
2✔
404
    }
405

406
    public function getPaginationClientEnabled(): ?bool
407
    {
408
        return $this->paginationClientEnabled;
852✔
409
    }
410

411
    public function withPaginationClientEnabled(bool $paginationClientEnabled): static
412
    {
413
        $self = clone $this;
131✔
414
        $self->paginationClientEnabled = $paginationClientEnabled;
131✔
415

416
        return $self;
131✔
417
    }
418

419
    public function getPaginationClientItemsPerPage(): ?bool
420
    {
421
        return $this->paginationClientItemsPerPage;
897✔
422
    }
423

424
    public function withPaginationClientItemsPerPage(bool $paginationClientItemsPerPage): static
425
    {
426
        $self = clone $this;
131✔
427
        $self->paginationClientItemsPerPage = $paginationClientItemsPerPage;
131✔
428

429
        return $self;
131✔
430
    }
431

432
    public function getPaginationClientPartial(): ?bool
433
    {
434
        return $this->paginationClientPartial;
605✔
435
    }
436

437
    public function withPaginationClientPartial(bool $paginationClientPartial): static
438
    {
439
        $self = clone $this;
131✔
440
        $self->paginationClientPartial = $paginationClientPartial;
131✔
441

442
        return $self;
131✔
443
    }
444

445
    public function getPaginationFetchJoinCollection(): ?bool
446
    {
447
        return $this->paginationFetchJoinCollection;
605✔
448
    }
449

450
    public function withPaginationFetchJoinCollection(bool $paginationFetchJoinCollection): static
451
    {
452
        $self = clone $this;
×
453
        $self->paginationFetchJoinCollection = $paginationFetchJoinCollection;
×
454

455
        return $self;
×
456
    }
457

458
    public function getPaginationUseOutputWalkers(): ?bool
459
    {
460
        return $this->paginationUseOutputWalkers;
605✔
461
    }
462

463
    public function withPaginationUseOutputWalkers(bool $paginationUseOutputWalkers): static
464
    {
465
        $self = clone $this;
×
466
        $self->paginationUseOutputWalkers = $paginationUseOutputWalkers;
×
467

468
        return $self;
×
469
    }
470

471
    public function getSecurity(): ?string
472
    {
473
        return $this->security instanceof \Stringable ? (string) $this->security : $this->security;
2,030✔
474
    }
475

476
    public function withSecurity($security): static
477
    {
478
        $self = clone $this;
8✔
479
        $self->security = $security;
8✔
480

481
        return $self;
8✔
482
    }
483

484
    public function getSecurityMessage(): ?string
485
    {
486
        return $this->securityMessage;
2,018✔
487
    }
488

489
    public function withSecurityMessage(string $securityMessage): static
490
    {
491
        $self = clone $this;
×
492
        $self->securityMessage = $securityMessage;
×
493

494
        return $self;
×
495
    }
496

497
    public function getSecurityPostDenormalize(): ?string
498
    {
499
        return $this->securityPostDenormalize instanceof \Stringable ? (string) $this->securityPostDenormalize : $this->securityPostDenormalize;
1,829✔
500
    }
501

502
    public function withSecurityPostDenormalize($securityPostDenormalize): static
503
    {
504
        $self = clone $this;
×
505
        $self->securityPostDenormalize = $securityPostDenormalize;
×
506

507
        return $self;
×
508
    }
509

510
    public function getSecurityPostDenormalizeMessage(): ?string
511
    {
512
        return $this->securityPostDenormalizeMessage;
1,829✔
513
    }
514

515
    public function withSecurityPostDenormalizeMessage(string $securityPostDenormalizeMessage): static
516
    {
517
        $self = clone $this;
×
518
        $self->securityPostDenormalizeMessage = $securityPostDenormalizeMessage;
×
519

520
        return $self;
×
521
    }
522

523
    public function getSecurityPostValidation(): ?string
524
    {
525
        return $this->securityPostValidation instanceof \Stringable ? (string) $this->securityPostValidation : $this->securityPostValidation;
2,007✔
526
    }
527

528
    public function withSecurityPostValidation(string|\Stringable|null $securityPostValidation = null): static
529
    {
530
        $self = clone $this;
×
531
        $self->securityPostValidation = $securityPostValidation;
×
532

533
        return $self;
×
534
    }
535

536
    public function getSecurityPostValidationMessage(): ?string
537
    {
538
        return $this->securityPostValidationMessage;
2,007✔
539
    }
540

541
    public function withSecurityPostValidationMessage(?string $securityPostValidationMessage = null): static
542
    {
543
        $self = clone $this;
×
544
        $self->securityPostValidationMessage = $securityPostValidationMessage;
×
545

546
        return $self;
×
547
    }
548

549
    public function getProcessor(): callable|string|null
550
    {
551
        return $this->processor;
652✔
552
    }
553

554
    public function withProcessor(callable|string|null $processor): static
555
    {
556
        $self = clone $this;
95✔
557
        $self->processor = $processor;
95✔
558

559
        return $self;
95✔
560
    }
561

562
    public function getProvider(): callable|string|null
563
    {
564
        return $this->provider;
1,756✔
565
    }
566

567
    public function withProvider(callable|string|null $provider): static
568
    {
569
        $self = clone $this;
104✔
570
        $self->provider = $provider;
104✔
571

572
        return $self;
104✔
573
    }
574

575
    public function getStateOptions(): ?OptionsInterface
576
    {
577
        return $this->stateOptions;
1,945✔
578
    }
579

580
    public function withStateOptions(?OptionsInterface $stateOptions): static
581
    {
582
        $self = clone $this;
89✔
583
        $self->stateOptions = $stateOptions;
89✔
584

585
        return $self;
89✔
586
    }
587

588
    /**
589
     * @return string|callable|array<string, \Illuminate\Contracts\Validation\Rule|array|string>
590
     */
591
    public function getRules(): mixed
592
    {
593
        return $this->rules;
140✔
594
    }
595

596
    /**
597
     * @param string|callable|array<string, \Illuminate\Contracts\Validation\Rule|array|string> $rules
598
     */
599
    public function withRules(mixed $rules): static
600
    {
601
        $self = clone $this;
×
602
        $self->rules = $rules;
×
603

604
        return $self;
×
605
    }
606

607
    public function getParameters(): ?Parameters
608
    {
609
        return $this->parameters;
2,073✔
610
    }
611

612
    public function withParameters(array|Parameters $parameters): static
613
    {
614
        $self = clone $this;
771✔
615
        $self->parameters = \is_array($parameters) ? new Parameters($parameters) : $parameters;
771✔
616

617
        return $self;
771✔
618
    }
619

620
    public function getQueryParameterValidationEnabled(): ?bool
621
    {
622
        return $this->queryParameterValidationEnabled;
1,759✔
623
    }
624

625
    public function withQueryParameterValidationEnabled(bool $queryParameterValidationEnabled): static
626
    {
627
        $self = clone $this;
×
628
        $self->queryParameterValidationEnabled = $queryParameterValidationEnabled;
×
629

630
        return $self;
×
631
    }
632

633
    public function getPolicy(): ?string
634
    {
635
        return $this->policy;
140✔
636
    }
637

638
    public function withPolicy(string $policy): static
639
    {
640
        $self = clone $this;
×
641
        $self->policy = $policy;
×
642

643
        return $self;
×
644
    }
645

646
    public function getMiddleware(): mixed
647
    {
648
        return $this->middleware;
140✔
649
    }
650

651
    public function withMiddleware(string|array $middleware): static
652
    {
653
        $self = clone $this;
×
654
        $self->middleware = $middleware;
×
655

656
        return $self;
×
657
    }
658

659
    public function getExtraProperties(): ?array
660
    {
661
        return $this->extraProperties;
1,337✔
662
    }
663

664
    public function withExtraProperties(array $extraProperties = []): static
665
    {
666
        $self = clone $this;
140✔
667
        $self->extraProperties = $extraProperties;
140✔
668

669
        return $self;
140✔
670
    }
671

672
    public function getStrictQueryParameterValidation(): ?bool
673
    {
674
        return $this->strictQueryParameterValidation;
1,759✔
675
    }
676

677
    public function withStrictQueryParameterValidation(bool $strictQueryParameterValidation): static
678
    {
679
        $self = clone $this;
×
680
        $self->strictQueryParameterValidation = $strictQueryParameterValidation;
×
681

682
        return $self;
×
683
    }
684

685
    public function getHideHydraOperation(): ?bool
686
    {
687
        return $this->hideHydraOperation;
158✔
688
    }
689

690
    public function withHideHydraOperation(bool $hideHydraOperation): static
691
    {
692
        $self = clone $this;
4✔
693
        $self->hideHydraOperation = $hideHydraOperation;
4✔
694

695
        return $self;
4✔
696
    }
697
}
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