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

api-platform / core / 10729306835

05 Sep 2024 10:46PM UTC coverage: 7.655% (-0.01%) from 7.665%
10729306835

push

github

web-flow
Merge pull request #6586 from soyuka/merge-342

Merge 3.4

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

8760 existing lines in 277 files now uncovered.

12505 of 163357 relevant lines covered (7.66%)

22.84 hits per line

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

69.14
/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 array $extraProperties = [],
85
    ) {
UNCOV
86
        if (\is_array($parameters) && $parameters) {
2,036✔
UNCOV
87
            $parameters = new Parameters($parameters);
3✔
88
        }
89

UNCOV
90
        $this->parameters = $parameters;
2,036✔
91
    }
92

93
    public function getShortName(): ?string
94
    {
UNCOV
95
        return $this->shortName;
1,935✔
96
    }
97

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

UNCOV
103
        return $self;
50✔
104
    }
105

106
    public function getClass(): ?string
107
    {
UNCOV
108
        return $this->class;
2,249✔
109
    }
110

111
    public function withClass(string $class): static
112
    {
UNCOV
113
        $self = clone $this;
1,907✔
UNCOV
114
        $self->class = $class;
1,907✔
115

UNCOV
116
        return $self;
1,907✔
117
    }
118

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

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

UNCOV
129
        return $self;
43✔
130
    }
131

132
    public function getUrlGenerationStrategy(): ?int
133
    {
UNCOV
134
        return $this->urlGenerationStrategy;
2,018✔
135
    }
136

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

UNCOV
142
        return $self;
3✔
143
    }
144

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

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

UNCOV
155
        return $self;
3✔
156
    }
157

158
    public function getNormalizationContext(): ?array
159
    {
UNCOV
160
        return $this->normalizationContext;
2,248✔
161
    }
162

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

UNCOV
168
        return $self;
266✔
169
    }
170

171
    public function getDenormalizationContext(): ?array
172
    {
UNCOV
173
        return $this->denormalizationContext;
1,725✔
174
    }
175

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

UNCOV
181
        return $self;
4✔
182
    }
183

184
    public function getCollectDenormalizationErrors(): ?bool
185
    {
UNCOV
186
        return $this->collectDenormalizationErrors;
1,841✔
187
    }
188

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

194
        return $self;
1✔
195
    }
196

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

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

207
        return $self;
×
208
    }
209

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

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

UNCOV
223
        return $self;
34✔
224
    }
225

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

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

242
        return $self;
×
243
    }
244

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

253
    public function withMercure($mercure): static
254
    {
UNCOV
255
        $self = clone $this;
3✔
UNCOV
256
        $self->mercure = $mercure;
3✔
257

UNCOV
258
        return $self;
3✔
259
    }
260

261
    public function getMessenger()
262
    {
UNCOV
263
        return $this->messenger;
34✔
264
    }
265

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

271
        return $self;
×
272
    }
273

274
    public function getInput()
275
    {
UNCOV
276
        return $this->input;
2,249✔
277
    }
278

279
    public function withInput($input): static
280
    {
UNCOV
281
        $self = clone $this;
34✔
UNCOV
282
        $self->input = $input;
34✔
283

UNCOV
284
        return $self;
34✔
285
    }
286

287
    public function getOutput()
288
    {
UNCOV
289
        return $this->output;
2,249✔
290
    }
291

292
    public function withOutput($output): static
293
    {
UNCOV
294
        $self = clone $this;
34✔
UNCOV
295
        $self->output = $output;
34✔
296

UNCOV
297
        return $self;
34✔
298
    }
299

300
    public function getOrder(): ?array
301
    {
UNCOV
302
        return $this->order;
809✔
303
    }
304

305
    public function withOrder(array $order): static
306
    {
UNCOV
307
        $self = clone $this;
3✔
UNCOV
308
        $self->order = $order;
3✔
309

UNCOV
310
        return $self;
3✔
311
    }
312

313
    public function getFetchPartial(): ?bool
314
    {
UNCOV
315
        return $this->fetchPartial;
550✔
316
    }
317

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

323
        return $self;
×
324
    }
325

326
    public function getForceEager(): ?bool
327
    {
UNCOV
328
        return $this->forceEager;
550✔
329
    }
330

331
    public function withForceEager(bool $forceEager): static
332
    {
UNCOV
333
        $self = clone $this;
3✔
UNCOV
334
        $self->forceEager = $forceEager;
3✔
335

UNCOV
336
        return $self;
3✔
337
    }
338

339
    public function getPaginationEnabled(): ?bool
340
    {
UNCOV
341
        return $this->paginationEnabled;
1,152✔
342
    }
343

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

349
        return $self;
×
350
    }
351

352
    public function getPaginationType(): ?string
353
    {
UNCOV
354
        return $this->paginationType;
439✔
355
    }
356

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

362
        return $self;
×
363
    }
364

365
    public function getPaginationItemsPerPage(): ?int
366
    {
UNCOV
367
        return $this->paginationItemsPerPage;
881✔
368
    }
369

370
    public function withPaginationItemsPerPage(int $paginationItemsPerPage): static
371
    {
UNCOV
372
        $self = clone $this;
34✔
UNCOV
373
        $self->paginationItemsPerPage = $paginationItemsPerPage;
34✔
374

UNCOV
375
        return $self;
34✔
376
    }
377

378
    public function getPaginationMaximumItemsPerPage(): ?int
379
    {
UNCOV
380
        return $this->paginationMaximumItemsPerPage;
881✔
381
    }
382

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

388
        return $self;
×
389
    }
390

391
    public function getPaginationPartial(): ?bool
392
    {
UNCOV
393
        return $this->paginationPartial;
309✔
394
    }
395

396
    public function withPaginationPartial(bool $paginationPartial): static
397
    {
UNCOV
398
        $self = clone $this;
3✔
UNCOV
399
        $self->paginationPartial = $paginationPartial;
3✔
400

UNCOV
401
        return $self;
3✔
402
    }
403

404
    public function getPaginationClientEnabled(): ?bool
405
    {
UNCOV
406
        return $this->paginationClientEnabled;
844✔
407
    }
408

409
    public function withPaginationClientEnabled(bool $paginationClientEnabled): static
410
    {
UNCOV
411
        $self = clone $this;
34✔
UNCOV
412
        $self->paginationClientEnabled = $paginationClientEnabled;
34✔
413

UNCOV
414
        return $self;
34✔
415
    }
416

417
    public function getPaginationClientItemsPerPage(): ?bool
418
    {
UNCOV
419
        return $this->paginationClientItemsPerPage;
881✔
420
    }
421

422
    public function withPaginationClientItemsPerPage(bool $paginationClientItemsPerPage): static
423
    {
UNCOV
424
        $self = clone $this;
34✔
UNCOV
425
        $self->paginationClientItemsPerPage = $paginationClientItemsPerPage;
34✔
426

UNCOV
427
        return $self;
34✔
428
    }
429

430
    public function getPaginationClientPartial(): ?bool
431
    {
UNCOV
432
        return $this->paginationClientPartial;
309✔
433
    }
434

435
    public function withPaginationClientPartial(bool $paginationClientPartial): static
436
    {
UNCOV
437
        $self = clone $this;
34✔
UNCOV
438
        $self->paginationClientPartial = $paginationClientPartial;
34✔
439

UNCOV
440
        return $self;
34✔
441
    }
442

443
    public function getPaginationFetchJoinCollection(): ?bool
444
    {
UNCOV
445
        return $this->paginationFetchJoinCollection;
309✔
446
    }
447

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

453
        return $self;
×
454
    }
455

456
    public function getPaginationUseOutputWalkers(): ?bool
457
    {
UNCOV
458
        return $this->paginationUseOutputWalkers;
309✔
459
    }
460

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

466
        return $self;
×
467
    }
468

469
    public function getSecurity(): ?string
470
    {
UNCOV
471
        return $this->security instanceof \Stringable ? (string) $this->security : $this->security;
2,187✔
472
    }
473

474
    public function withSecurity($security): static
475
    {
UNCOV
476
        $self = clone $this;
4✔
UNCOV
477
        $self->security = $security;
4✔
478

UNCOV
479
        return $self;
4✔
480
    }
481

482
    public function getSecurityMessage(): ?string
483
    {
UNCOV
484
        return $this->securityMessage;
2,187✔
485
    }
486

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

492
        return $self;
×
493
    }
494

495
    public function getSecurityPostDenormalize(): ?string
496
    {
UNCOV
497
        return $this->securityPostDenormalize instanceof \Stringable ? (string) $this->securityPostDenormalize : $this->securityPostDenormalize;
2,187✔
498
    }
499

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

505
        return $self;
×
506
    }
507

508
    public function getSecurityPostDenormalizeMessage(): ?string
509
    {
UNCOV
510
        return $this->securityPostDenormalizeMessage;
2,187✔
511
    }
512

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

518
        return $self;
×
519
    }
520

521
    public function getSecurityPostValidation(): ?string
522
    {
UNCOV
523
        return $this->securityPostValidation instanceof \Stringable ? (string) $this->securityPostValidation : $this->securityPostValidation;
2,187✔
524
    }
525

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

531
        return $self;
×
532
    }
533

534
    public function getSecurityPostValidationMessage(): ?string
535
    {
UNCOV
536
        return $this->securityPostValidationMessage;
2,187✔
537
    }
538

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

544
        return $self;
×
545
    }
546

547
    public function getProcessor(): callable|string|null
548
    {
UNCOV
549
        return $this->processor;
725✔
550
    }
551

552
    public function withProcessor(callable|string|null $processor): static
553
    {
UNCOV
554
        $self = clone $this;
33✔
UNCOV
555
        $self->processor = $processor;
33✔
556

UNCOV
557
        return $self;
33✔
558
    }
559

560
    public function getProvider(): callable|string|null
561
    {
UNCOV
562
        return $this->provider;
1,817✔
563
    }
564

565
    public function withProvider(callable|string|null $provider): static
566
    {
UNCOV
567
        $self = clone $this;
31✔
UNCOV
568
        $self->provider = $provider;
31✔
569

UNCOV
570
        return $self;
31✔
571
    }
572

573
    public function getStateOptions(): ?OptionsInterface
574
    {
UNCOV
575
        return $this->stateOptions;
2,220✔
576
    }
577

578
    public function withStateOptions(?OptionsInterface $stateOptions): static
579
    {
UNCOV
580
        $self = clone $this;
30✔
UNCOV
581
        $self->stateOptions = $stateOptions;
30✔
582

UNCOV
583
        return $self;
30✔
584
    }
585

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

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

602
        return $self;
×
603
    }
604

605
    public function getParameters(): ?Parameters
606
    {
UNCOV
607
        return $this->parameters;
2,249✔
608
    }
609

610
    public function withParameters(array|Parameters $parameters): static
611
    {
UNCOV
612
        $self = clone $this;
1,085✔
UNCOV
613
        $self->parameters = \is_array($parameters) ? new Parameters($parameters) : $parameters;
1,085✔
614

UNCOV
615
        return $self;
1,085✔
616
    }
617

618
    public function getQueryParameterValidationEnabled(): ?bool
619
    {
UNCOV
620
        return $this->queryParameterValidationEnabled;
1,850✔
621
    }
622

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

628
        return $self;
×
629
    }
630

631
    public function getPolicy(): ?string
632
    {
UNCOV
633
        return $this->policy;
34✔
634
    }
635

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

641
        return $self;
×
642
    }
643

644
    public function getMiddleware(): mixed
645
    {
UNCOV
646
        return $this->middleware;
34✔
647
    }
648

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

654
        return $self;
×
655
    }
656

657
    public function getExtraProperties(): ?array
658
    {
UNCOV
659
        return $this->extraProperties;
1,212✔
660
    }
661

662
    public function withExtraProperties(array $extraProperties = []): static
663
    {
UNCOV
664
        $self = clone $this;
34✔
UNCOV
665
        $self->extraProperties = $extraProperties;
34✔
666

UNCOV
667
        return $self;
34✔
668
    }
669
}
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