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

api-platform / core / 10014117656

19 Jul 2024 08:44PM UTC coverage: 7.856% (-56.3%) from 64.185%
10014117656

push

github

soyuka
Merge branch 'sf/remove-flag'

0 of 527 new or added lines in 83 files covered. (0.0%)

10505 existing lines in 362 files now uncovered.

12705 of 161727 relevant lines covered (7.86%)

26.85 hits per line

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

71.26
/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 ?bool $queryParameterValidationEnabled = null,
82
        protected array $extraProperties = []
83
    ) {
UNCOV
84
        if (\is_array($parameters) && $parameters) {
2,728✔
UNCOV
85
            $parameters = new Parameters($parameters);
15✔
86
        }
87

UNCOV
88
        $this->parameters = $parameters;
2,728✔
89
    }
90

91
    public function getShortName(): ?string
92
    {
UNCOV
93
        return $this->shortName;
2,382✔
94
    }
95

96
    public function withShortName(string $shortName): static
97
    {
UNCOV
98
        $self = clone $this;
223✔
UNCOV
99
        $self->shortName = $shortName;
223✔
100

UNCOV
101
        return $self;
223✔
102
    }
103

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

109
    public function withClass(string $class): static
110
    {
UNCOV
111
        $self = clone $this;
2,251✔
UNCOV
112
        $self->class = $class;
2,251✔
113

UNCOV
114
        return $self;
2,251✔
115
    }
116

117
    public function getDescription(): ?string
118
    {
UNCOV
119
        return $this->description;
693✔
120
    }
121

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

UNCOV
127
        return $self;
94✔
128
    }
129

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

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

UNCOV
140
        return $self;
3✔
141
    }
142

143
    public function getDeprecationReason(): ?string
144
    {
UNCOV
145
        return $this->deprecationReason;
693✔
146
    }
147

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

UNCOV
153
        return $self;
3✔
154
    }
155

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

161
    public function withNormalizationContext(array $normalizationContext): static
162
    {
UNCOV
163
        $self = clone $this;
407✔
UNCOV
164
        $self->normalizationContext = $normalizationContext;
407✔
165

UNCOV
166
        return $self;
407✔
167
    }
168

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

174
    public function withDenormalizationContext(array $denormalizationContext): static
175
    {
UNCOV
176
        $self = clone $this;
10✔
UNCOV
177
        $self->denormalizationContext = $denormalizationContext;
10✔
178

UNCOV
179
        return $self;
10✔
180
    }
181

182
    public function getCollectDenormalizationErrors(): ?bool
183
    {
UNCOV
184
        return $this->collectDenormalizationErrors;
2,198✔
185
    }
186

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

UNCOV
192
        return $self;
1✔
193
    }
194

195
    public function getValidationContext(): ?array
196
    {
UNCOV
197
        return $this->validationContext;
903✔
198
    }
199

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

205
        return $self;
×
206
    }
207

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

216
    public function withFilters(array $filters): static
217
    {
UNCOV
218
        $self = clone $this;
111✔
UNCOV
219
        $self->filters = $filters;
111✔
220

UNCOV
221
        return $self;
111✔
222
    }
223

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

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

240
        return $self;
×
241
    }
242

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

251
    public function withMercure($mercure): static
252
    {
UNCOV
253
        $self = clone $this;
15✔
UNCOV
254
        $self->mercure = $mercure;
15✔
255

UNCOV
256
        return $self;
15✔
257
    }
258

259
    public function getMessenger()
260
    {
UNCOV
261
        return $this->messenger;
108✔
262
    }
263

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

269
        return $self;
×
270
    }
271

272
    public function getInput()
273
    {
UNCOV
274
        return $this->input;
2,651✔
275
    }
276

277
    public function withInput($input): static
278
    {
UNCOV
279
        $self = clone $this;
141✔
UNCOV
280
        $self->input = $input;
141✔
281

UNCOV
282
        return $self;
141✔
283
    }
284

285
    public function getOutput()
286
    {
UNCOV
287
        return $this->output;
2,684✔
288
    }
289

290
    public function withOutput($output): static
291
    {
UNCOV
292
        $self = clone $this;
99✔
UNCOV
293
        $self->output = $output;
99✔
294

UNCOV
295
        return $self;
99✔
296
    }
297

298
    public function getOrder(): ?array
299
    {
UNCOV
300
        return $this->order;
925✔
301
    }
302

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

UNCOV
308
        return $self;
3✔
309
    }
310

311
    public function getFetchPartial(): ?bool
312
    {
UNCOV
313
        return $this->fetchPartial;
687✔
314
    }
315

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

321
        return $self;
×
322
    }
323

324
    public function getForceEager(): ?bool
325
    {
UNCOV
326
        return $this->forceEager;
687✔
327
    }
328

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

UNCOV
334
        return $self;
3✔
335
    }
336

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

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

347
        return $self;
×
348
    }
349

350
    public function getPaginationType(): ?string
351
    {
UNCOV
352
        return $this->paginationType;
519✔
353
    }
354

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

360
        return $self;
×
361
    }
362

363
    public function getPaginationItemsPerPage(): ?int
364
    {
UNCOV
365
        return $this->paginationItemsPerPage;
1,015✔
366
    }
367

368
    public function withPaginationItemsPerPage(int $paginationItemsPerPage): static
369
    {
UNCOV
370
        $self = clone $this;
99✔
UNCOV
371
        $self->paginationItemsPerPage = $paginationItemsPerPage;
99✔
372

UNCOV
373
        return $self;
99✔
374
    }
375

376
    public function getPaginationMaximumItemsPerPage(): ?int
377
    {
UNCOV
378
        return $this->paginationMaximumItemsPerPage;
1,015✔
379
    }
380

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

386
        return $self;
×
387
    }
388

389
    public function getPaginationPartial(): ?bool
390
    {
UNCOV
391
        return $this->paginationPartial;
425✔
392
    }
393

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

UNCOV
399
        return $self;
3✔
400
    }
401

402
    public function getPaginationClientEnabled(): ?bool
403
    {
UNCOV
404
        return $this->paginationClientEnabled;
975✔
405
    }
406

407
    public function withPaginationClientEnabled(bool $paginationClientEnabled): static
408
    {
UNCOV
409
        $self = clone $this;
99✔
UNCOV
410
        $self->paginationClientEnabled = $paginationClientEnabled;
99✔
411

UNCOV
412
        return $self;
99✔
413
    }
414

415
    public function getPaginationClientItemsPerPage(): ?bool
416
    {
UNCOV
417
        return $this->paginationClientItemsPerPage;
1,015✔
418
    }
419

420
    public function withPaginationClientItemsPerPage(bool $paginationClientItemsPerPage): static
421
    {
UNCOV
422
        $self = clone $this;
99✔
UNCOV
423
        $self->paginationClientItemsPerPage = $paginationClientItemsPerPage;
99✔
424

UNCOV
425
        return $self;
99✔
426
    }
427

428
    public function getPaginationClientPartial(): ?bool
429
    {
UNCOV
430
        return $this->paginationClientPartial;
425✔
431
    }
432

433
    public function withPaginationClientPartial(bool $paginationClientPartial): static
434
    {
UNCOV
435
        $self = clone $this;
99✔
UNCOV
436
        $self->paginationClientPartial = $paginationClientPartial;
99✔
437

UNCOV
438
        return $self;
99✔
439
    }
440

441
    public function getPaginationFetchJoinCollection(): ?bool
442
    {
UNCOV
443
        return $this->paginationFetchJoinCollection;
425✔
444
    }
445

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

451
        return $self;
×
452
    }
453

454
    public function getPaginationUseOutputWalkers(): ?bool
455
    {
UNCOV
456
        return $this->paginationUseOutputWalkers;
425✔
457
    }
458

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

464
        return $self;
×
465
    }
466

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

472
    public function withSecurity($security): static
473
    {
UNCOV
474
        $self = clone $this;
7✔
UNCOV
475
        $self->security = $security;
7✔
476

UNCOV
477
        return $self;
7✔
478
    }
479

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

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

490
        return $self;
×
491
    }
492

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

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

503
        return $self;
×
504
    }
505

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

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

516
        return $self;
×
517
    }
518

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

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

529
        return $self;
×
530
    }
531

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

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

542
        return $self;
×
543
    }
544

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

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

UNCOV
555
        return $self;
69✔
556
    }
557

558
    public function getProvider(): callable|string|null
559
    {
UNCOV
560
        return $this->provider;
2,189✔
561
    }
562

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

UNCOV
568
        return $self;
76✔
569
    }
570

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

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

UNCOV
581
        return $self;
60✔
582
    }
583

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

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

600
        return $self;
×
601
    }
602

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

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

UNCOV
613
        return $self;
1,256✔
614
    }
615

616
    public function getQueryParameterValidationEnabled(): ?bool
617
    {
UNCOV
618
        return $this->queryParameterValidationEnabled;
2,202✔
619
    }
620

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

626
        return $self;
×
627
    }
628

629
    public function getExtraProperties(): ?array
630
    {
UNCOV
631
        return $this->extraProperties;
1,389✔
632
    }
633

634
    public function withExtraProperties(array $extraProperties = []): static
635
    {
UNCOV
636
        $self = clone $this;
108✔
UNCOV
637
        $self->extraProperties = $extraProperties;
108✔
638

UNCOV
639
        return $self;
108✔
640
    }
641
}
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