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

api-platform / core / 15955054194

29 Jun 2025 12:10PM UTC coverage: 22.026% (+0.2%) from 21.793%
15955054194

push

github

soyuka
cs: unused namespace

11500 of 52210 relevant lines covered (22.03%)

21.66 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
    {
30
    }
580✔
31

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

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

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

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

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

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

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

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

65
        return $resourceMetadataCollection;
6✔
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