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

api-platform / core / 9710726294

25 Jun 2024 02:01PM UTC coverage: 62.122% (-0.5%) from 62.637%
9710726294

push

github

web-flow
feat(laravel): laravel component (#5882)

* feat(laravel): laravel component

* try to skip laravel

* feat(jsonapi): component

* feat(laravel): json api support (needs review)

* work on relations

* relations (needs toMany) + skolem + IRI to resource

* links handler

* ulid

* validation

* slug post

* remove deprecations

* move classes

* fix tests

* fix tests metadata

* phpstan

* missing class

* fix laravel tests

* fix stan

33 of 77 new or added lines in 20 files covered. (42.86%)

140 existing lines in 15 files now uncovered.

10862 of 17485 relevant lines covered (62.12%)

59.64 hits per line

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

72.05
/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
    /**
24
     * @param string|null                                                                       $deprecationReason       https://api-platform.com/docs/core/deprecations/#deprecating-resource-classes-operations-and-properties
25
     * @param string|\Stringable|null                                                           $security                https://api-platform.com/docs/core/security
26
     * @param string|\Stringable|null                                                           $securityPostDenormalize https://api-platform.com/docs/core/security/#executing-access-control-rules-after-denormalization
27
     * @param mixed|null                                                                        $mercure
28
     * @param mixed|null                                                                        $messenger
29
     * @param mixed|null                                                                        $input
30
     * @param mixed|null                                                                        $output
31
     * @param mixed|null                                                                        $provider
32
     * @param mixed|null                                                                        $processor
33
     * @param Parameters|array<string, Parameter>                                               $parameters
34
     * @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
35
     */
36
    public function __construct(
37
        protected ?string $shortName = null,
38
        protected ?string $class = null,
39
        protected ?string $description = null,
40
        protected ?int $urlGenerationStrategy = null,
41
        protected ?string $deprecationReason = null,
42
        protected ?array $normalizationContext = null,
43
        protected ?array $denormalizationContext = null,
44
        protected ?bool $collectDenormalizationErrors = null,
45
        protected ?array $validationContext = null,
46
        protected ?array $filters = null,
47
        protected ?bool $elasticsearch = null,
48
        protected $mercure = null,
49
        protected $messenger = null,
50
        protected $input = null,
51
        protected $output = null,
52
        protected ?array $order = null,
53
        protected ?bool $fetchPartial = null,
54
        protected ?bool $forceEager = null,
55
        protected ?bool $paginationEnabled = null,
56
        protected ?string $paginationType = null,
57
        protected ?int $paginationItemsPerPage = null,
58
        protected ?int $paginationMaximumItemsPerPage = null,
59
        protected ?bool $paginationPartial = null,
60
        protected ?bool $paginationClientEnabled = null,
61
        protected ?bool $paginationClientItemsPerPage = null,
62
        protected ?bool $paginationClientPartial = null,
63
        protected ?bool $paginationFetchJoinCollection = null,
64
        protected ?bool $paginationUseOutputWalkers = null,
65
        protected string|\Stringable|null $security = null,
66
        protected ?string $securityMessage = null,
67
        protected string|\Stringable|null $securityPostDenormalize = null,
68
        protected ?string $securityPostDenormalizeMessage = null,
69
        protected string|\Stringable|null $securityPostValidation = null,
70
        protected ?string $securityPostValidationMessage = null,
71
        protected $provider = null,
72
        protected $processor = null,
73
        protected ?OptionsInterface $stateOptions = null,
74
        /**
75
         * @experimental
76
         */
77
        protected array|Parameters|null $parameters = [],
78
        protected mixed $rules = null,
79
        protected array $extraProperties = [],
80
    ) {
81
    }
1,164✔
82

83
    public function getShortName(): ?string
84
    {
85
        return $this->shortName;
516✔
86
    }
87

88
    public function withShortName(string $shortName): static
89
    {
90
        $self = clone $this;
240✔
91
        $self->shortName = $shortName;
240✔
92

93
        return $self;
240✔
94
    }
95

96
    public function getClass(): ?string
97
    {
98
        return $this->class;
492✔
99
    }
100

101
    public function withClass(string $class): static
102
    {
103
        $self = clone $this;
300✔
104
        $self->class = $class;
300✔
105

106
        return $self;
300✔
107
    }
108

109
    public function getDescription(): ?string
110
    {
111
        return $this->description;
268✔
112
    }
113

114
    public function withDescription(?string $description = null): static
115
    {
116
        $self = clone $this;
28✔
117
        $self->description = $description;
28✔
118

119
        return $self;
28✔
120
    }
121

122
    public function getUrlGenerationStrategy(): ?int
123
    {
124
        return $this->urlGenerationStrategy;
376✔
125
    }
126

127
    public function withUrlGenerationStrategy(int $urlGenerationStrategy): static
128
    {
129
        $self = clone $this;
4✔
130
        $self->urlGenerationStrategy = $urlGenerationStrategy;
4✔
131

132
        return $self;
4✔
133
    }
134

135
    public function getDeprecationReason(): ?string
136
    {
137
        return $this->deprecationReason;
268✔
138
    }
139

140
    public function withDeprecationReason($deprecationReason): static
141
    {
142
        $self = clone $this;
4✔
143
        $self->deprecationReason = $deprecationReason;
4✔
144

145
        return $self;
4✔
146
    }
147

148
    public function getNormalizationContext(): ?array
149
    {
150
        return $this->normalizationContext;
508✔
151
    }
152

153
    public function withNormalizationContext(array $normalizationContext): static
154
    {
155
        $self = clone $this;
44✔
156
        $self->normalizationContext = $normalizationContext;
44✔
157

158
        return $self;
44✔
159
    }
160

161
    public function getDenormalizationContext(): ?array
162
    {
163
        return $this->denormalizationContext;
332✔
164
    }
165

166
    public function withDenormalizationContext(array $denormalizationContext): static
167
    {
168
        $self = clone $this;
4✔
169
        $self->denormalizationContext = $denormalizationContext;
4✔
170

171
        return $self;
4✔
172
    }
173

174
    public function getCollectDenormalizationErrors(): ?bool
175
    {
176
        return $this->collectDenormalizationErrors;
328✔
177
    }
178

179
    public function withCollectDenormalizationErrors(?bool $collectDenormalizationErrors = null): static
180
    {
181
        $self = clone $this;
4✔
182
        $self->collectDenormalizationErrors = $collectDenormalizationErrors;
4✔
183

184
        return $self;
4✔
185
    }
186

187
    public function getValidationContext(): ?array
188
    {
189
        return $this->validationContext;
264✔
190
    }
191

192
    public function withValidationContext(array $validationContext): static
193
    {
194
        $self = clone $this;
×
195
        $self->validationContext = $validationContext;
×
196

197
        return $self;
×
198
    }
199

200
    /**
201
     * @return string[]|null
202
     */
203
    public function getFilters(): ?array
204
    {
205
        return $this->filters;
400✔
206
    }
207

208
    public function withFilters(array $filters): static
209
    {
210
        $self = clone $this;
36✔
211
        $self->filters = $filters;
36✔
212

213
        return $self;
36✔
214
    }
215

216
    /**
217
     * @deprecated this will be removed in v4
218
     */
219
    public function getElasticsearch(): ?bool
220
    {
221
        return $this->elasticsearch;
24✔
222
    }
223

224
    /**
225
     * @deprecated this will be removed in v4
226
     */
227
    public function withElasticsearch(bool $elasticsearch): static
228
    {
229
        $self = clone $this;
×
230
        $self->elasticsearch = $elasticsearch;
×
231

232
        return $self;
×
233
    }
234

235
    /**
236
     * @return array|bool|mixed|null
237
     */
238
    public function getMercure()
239
    {
240
        return $this->mercure;
368✔
241
    }
242

243
    public function withMercure($mercure): static
244
    {
245
        $self = clone $this;
16✔
246
        $self->mercure = $mercure;
16✔
247

248
        return $self;
16✔
249
    }
250

251
    public function getMessenger()
252
    {
253
        return $this->messenger;
24✔
254
    }
255

256
    public function withMessenger($messenger): static
257
    {
258
        $self = clone $this;
×
259
        $self->messenger = $messenger;
×
260

261
        return $self;
×
262
    }
263

264
    public function getInput()
265
    {
266
        return $this->input;
400✔
267
    }
268

269
    public function withInput($input): static
270
    {
271
        $self = clone $this;
76✔
272
        $self->input = $input;
76✔
273

274
        return $self;
76✔
275
    }
276

277
    public function getOutput()
278
    {
279
        return $this->output;
492✔
280
    }
281

282
    public function withOutput($output): static
283
    {
284
        $self = clone $this;
24✔
285
        $self->output = $output;
24✔
286

287
        return $self;
24✔
288
    }
289

290
    public function getOrder(): ?array
291
    {
292
        return $this->order;
76✔
293
    }
294

295
    public function withOrder(array $order): static
296
    {
297
        $self = clone $this;
4✔
298
        $self->order = $order;
4✔
299

300
        return $self;
4✔
301
    }
302

303
    public function getFetchPartial(): ?bool
304
    {
305
        return $this->fetchPartial;
100✔
306
    }
307

308
    public function withFetchPartial(bool $fetchPartial): static
309
    {
310
        $self = clone $this;
×
311
        $self->fetchPartial = $fetchPartial;
×
312

313
        return $self;
×
314
    }
315

316
    public function getForceEager(): ?bool
317
    {
318
        return $this->forceEager;
100✔
319
    }
320

321
    public function withForceEager(bool $forceEager): static
322
    {
323
        $self = clone $this;
4✔
324
        $self->forceEager = $forceEager;
4✔
325

326
        return $self;
4✔
327
    }
328

329
    public function getPaginationEnabled(): ?bool
330
    {
331
        return $this->paginationEnabled;
128✔
332
    }
333

334
    public function withPaginationEnabled(bool $paginationEnabled): static
335
    {
336
        $self = clone $this;
×
337
        $self->paginationEnabled = $paginationEnabled;
×
338

339
        return $self;
×
340
    }
341

342
    public function getPaginationType(): ?string
343
    {
344
        return $this->paginationType;
52✔
345
    }
346

347
    public function withPaginationType(string $paginationType): static
348
    {
349
        $self = clone $this;
×
350
        $self->paginationType = $paginationType;
×
351

352
        return $self;
×
353
    }
354

355
    public function getPaginationItemsPerPage(): ?int
356
    {
357
        return $this->paginationItemsPerPage;
100✔
358
    }
359

360
    public function withPaginationItemsPerPage(int $paginationItemsPerPage): static
361
    {
362
        $self = clone $this;
12✔
363
        $self->paginationItemsPerPage = $paginationItemsPerPage;
12✔
364

365
        return $self;
12✔
366
    }
367

368
    public function getPaginationMaximumItemsPerPage(): ?int
369
    {
370
        return $this->paginationMaximumItemsPerPage;
100✔
371
    }
372

373
    public function withPaginationMaximumItemsPerPage(int $paginationMaximumItemsPerPage): static
374
    {
375
        $self = clone $this;
×
376
        $self->paginationMaximumItemsPerPage = $paginationMaximumItemsPerPage;
×
377

378
        return $self;
×
379
    }
380

381
    public function getPaginationPartial(): ?bool
382
    {
383
        return $this->paginationPartial;
76✔
384
    }
385

386
    public function withPaginationPartial(bool $paginationPartial): static
387
    {
388
        $self = clone $this;
4✔
389
        $self->paginationPartial = $paginationPartial;
4✔
390

391
        return $self;
4✔
392
    }
393

394
    public function getPaginationClientEnabled(): ?bool
395
    {
396
        return $this->paginationClientEnabled;
100✔
397
    }
398

399
    public function withPaginationClientEnabled(bool $paginationClientEnabled): static
400
    {
401
        $self = clone $this;
12✔
402
        $self->paginationClientEnabled = $paginationClientEnabled;
12✔
403

404
        return $self;
12✔
405
    }
406

407
    public function getPaginationClientItemsPerPage(): ?bool
408
    {
409
        return $this->paginationClientItemsPerPage;
100✔
410
    }
411

412
    public function withPaginationClientItemsPerPage(bool $paginationClientItemsPerPage): static
413
    {
414
        $self = clone $this;
12✔
415
        $self->paginationClientItemsPerPage = $paginationClientItemsPerPage;
12✔
416

417
        return $self;
12✔
418
    }
419

420
    public function getPaginationClientPartial(): ?bool
421
    {
422
        return $this->paginationClientPartial;
76✔
423
    }
424

425
    public function withPaginationClientPartial(bool $paginationClientPartial): static
426
    {
427
        $self = clone $this;
12✔
428
        $self->paginationClientPartial = $paginationClientPartial;
12✔
429

430
        return $self;
12✔
431
    }
432

433
    public function getPaginationFetchJoinCollection(): ?bool
434
    {
435
        return $this->paginationFetchJoinCollection;
76✔
436
    }
437

438
    public function withPaginationFetchJoinCollection(bool $paginationFetchJoinCollection): static
439
    {
440
        $self = clone $this;
×
441
        $self->paginationFetchJoinCollection = $paginationFetchJoinCollection;
×
442

443
        return $self;
×
444
    }
445

446
    public function getPaginationUseOutputWalkers(): ?bool
447
    {
448
        return $this->paginationUseOutputWalkers;
76✔
449
    }
450

451
    public function withPaginationUseOutputWalkers(bool $paginationUseOutputWalkers): static
452
    {
453
        $self = clone $this;
×
454
        $self->paginationUseOutputWalkers = $paginationUseOutputWalkers;
×
455

456
        return $self;
×
457
    }
458

459
    public function getSecurity(): ?string
460
    {
461
        return $this->security instanceof \Stringable ? (string) $this->security : $this->security;
376✔
462
    }
463

464
    public function withSecurity($security): static
465
    {
466
        $self = clone $this;
4✔
467
        $self->security = $security;
4✔
468

469
        return $self;
4✔
470
    }
471

472
    public function getSecurityMessage(): ?string
473
    {
474
        return $this->securityMessage;
369✔
475
    }
476

477
    public function withSecurityMessage(string $securityMessage): static
478
    {
479
        $self = clone $this;
×
480
        $self->securityMessage = $securityMessage;
×
481

482
        return $self;
×
483
    }
484

485
    public function getSecurityPostDenormalize(): ?string
486
    {
487
        return $this->securityPostDenormalize instanceof \Stringable ? (string) $this->securityPostDenormalize : $this->securityPostDenormalize;
352✔
488
    }
489

490
    public function withSecurityPostDenormalize($securityPostDenormalize): static
491
    {
492
        $self = clone $this;
×
493
        $self->securityPostDenormalize = $securityPostDenormalize;
×
494

495
        return $self;
×
496
    }
497

498
    public function getSecurityPostDenormalizeMessage(): ?string
499
    {
500
        return $this->securityPostDenormalizeMessage;
345✔
501
    }
502

503
    public function withSecurityPostDenormalizeMessage(string $securityPostDenormalizeMessage): static
504
    {
505
        $self = clone $this;
×
506
        $self->securityPostDenormalizeMessage = $securityPostDenormalizeMessage;
×
507

508
        return $self;
×
509
    }
510

511
    public function getSecurityPostValidation(): ?string
512
    {
513
        return $this->securityPostValidation instanceof \Stringable ? (string) $this->securityPostValidation : $this->securityPostValidation;
345✔
514
    }
515

516
    public function withSecurityPostValidation(string|\Stringable|null $securityPostValidation = null): static
517
    {
518
        $self = clone $this;
×
519
        $self->securityPostValidation = $securityPostValidation;
×
520

521
        return $self;
×
522
    }
523

524
    public function getSecurityPostValidationMessage(): ?string
525
    {
526
        return $this->securityPostValidationMessage;
345✔
527
    }
528

529
    public function withSecurityPostValidationMessage(?string $securityPostValidationMessage = null): static
530
    {
531
        $self = clone $this;
×
532
        $self->securityPostValidationMessage = $securityPostValidationMessage;
×
533

534
        return $self;
×
535
    }
536

537
    public function getProcessor(): callable|string|null
538
    {
539
        return $this->processor;
88✔
540
    }
541

542
    public function withProcessor(callable|string|null $processor): static
543
    {
544
        $self = clone $this;
32✔
545
        $self->processor = $processor;
32✔
546

547
        return $self;
32✔
548
    }
549

550
    public function getProvider(): callable|string|null
551
    {
552
        return $this->provider;
348✔
553
    }
554

555
    public function withProvider(callable|string|null $provider): static
556
    {
557
        $self = clone $this;
16✔
558
        $self->provider = $provider;
16✔
559

560
        return $self;
16✔
561
    }
562

563
    public function getStateOptions(): ?OptionsInterface
564
    {
565
        return $this->stateOptions;
380✔
566
    }
567

568
    public function withStateOptions(?OptionsInterface $stateOptions): static
569
    {
570
        $self = clone $this;
8✔
571
        $self->stateOptions = $stateOptions;
8✔
572

573
        return $self;
8✔
574
    }
575

576
    /**
577
     * @return string|callable|array<string, \Illuminate\Contracts\Validation\Rule|array|string>
578
     */
579
    public function getRules(): mixed
580
    {
581
        return $this->rules;
24✔
582
    }
583

584
    /**
585
     * @param string|callable|array<string, \Illuminate\Contracts\Validation\Rule|array|string> $rules
586
     */
587
    public function withRules(mixed $rules): static
588
    {
NEW
589
        $self = clone $this;
×
NEW
590
        $self->rules = $rules;
×
591

NEW
592
        return $self;
×
593
    }
594

595
    /**
596
     * @return array<string, Parameter>
597
     */
598
    public function getParameters(): array|Parameters|null
599
    {
600
        return $this->parameters;
376✔
601
    }
602

603
    public function withParameters(array|Parameters $parameters): static
604
    {
605
        $self = clone $this;
329✔
606
        $self->parameters = $parameters;
329✔
607

608
        return $self;
329✔
609
    }
610

611
    public function getExtraProperties(): ?array
612
    {
613
        return $this->extraProperties;
260✔
614
    }
615

616
    public function withExtraProperties(array $extraProperties = []): static
617
    {
618
        $self = clone $this;
24✔
619
        $self->extraProperties = $extraProperties;
24✔
620

621
        return $self;
24✔
622
    }
623
}
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