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

api-platform / core / 15133993414

20 May 2025 09:30AM UTC coverage: 26.313% (-1.2%) from 27.493%
15133993414

Pull #7161

github

web-flow
Merge e2c03d45f into 5459ba375
Pull Request #7161: fix(metadata): infer parameter string type from schema

0 of 2 new or added lines in 1 file covered. (0.0%)

11019 existing lines in 363 files now uncovered.

12898 of 49018 relevant lines covered (26.31%)

34.33 hits per line

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

100.0
/src/Metadata/Resource/Factory/BackedEnumResourceMetadataCollectionFactory.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\Resource\Factory;
15

16
use ApiPlatform\Metadata\Operations;
17
use ApiPlatform\Metadata\Resource\ResourceMetadataCollection;
18

19
/**
20
 * Triggers resource deprecations.
21
 *
22
 * @internal
23
 */
24
final class BackedEnumResourceMetadataCollectionFactory implements ResourceMetadataCollectionFactoryInterface
25
{
26
    public const PROVIDER = 'api_platform.state_provider.backed_enum';
27

28
    public function __construct(private readonly ResourceMetadataCollectionFactoryInterface $decorated)
29
    {
UNCOV
30
    }
978✔
31

32
    public function create(string $resourceClass): ResourceMetadataCollection
33
    {
UNCOV
34
        $resourceMetadataCollection = $this->decorated->create($resourceClass);
69✔
UNCOV
35
        if (!is_a($resourceClass, \BackedEnum::class, true)) {
69✔
UNCOV
36
            return $resourceMetadataCollection;
67✔
37
        }
38

UNCOV
39
        foreach ($resourceMetadataCollection as $i => $resourceMetadata) {
5✔
UNCOV
40
            $newOperations = [];
3✔
UNCOV
41
            foreach ($resourceMetadata->getOperations() ?? [] as $operationName => $operation) {
3✔
UNCOV
42
                $newOperations[$operationName] = $operation;
3✔
43

UNCOV
44
                if (null !== $operation->getProvider()) {
3✔
UNCOV
45
                    continue;
2✔
46
                }
47

UNCOV
48
                $newOperations[$operationName] = $operation->withProvider(self::PROVIDER);
3✔
49
            }
50

UNCOV
51
            $newGraphQlOperations = [];
3✔
UNCOV
52
            foreach ($resourceMetadata->getGraphQlOperations() ?? [] as $operationName => $operation) {
3✔
UNCOV
53
                $newGraphQlOperations[$operationName] = $operation;
3✔
54

UNCOV
55
                if (null !== $operation->getProvider()) {
3✔
UNCOV
56
                    continue;
2✔
57
                }
58

UNCOV
59
                $newGraphQlOperations[$operationName] = $operation->withProvider(self::PROVIDER);
3✔
60
            }
61

UNCOV
62
            $resourceMetadataCollection[$i] = $resourceMetadata->withOperations(new Operations($newOperations))->withGraphQlOperations($newGraphQlOperations);
3✔
63
        }
64

UNCOV
65
        return $resourceMetadataCollection;
5✔
66
    }
67
}
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