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

api-platform / core / 13855495414

14 Mar 2025 11:19AM UTC coverage: 8.526% (-15.0%) from 23.51%
13855495414

Pull #7017

github

web-flow
Merge 0d3b24a16 into bf09616cf
Pull Request #7017: feat(metadata) Load external PHP file resources

22 of 78 new or added lines in 10 files covered. (28.21%)

36 existing lines in 2 files now uncovered.

13401 of 157170 relevant lines covered (8.53%)

22.93 hits per line

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

63.64
/src/Metadata/Resource/Factory/PhpFileResourceNameCollectionFactory.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\Extractor\ResourceExtractorInterface;
17
use ApiPlatform\Metadata\Resource\ResourceNameCollection;
18

19
/**
20
 * @internal
21
 */
22
final class PhpFileResourceNameCollectionFactory implements ResourceNameCollectionFactoryInterface
23
{
24
    public function __construct(
25
        private readonly ResourceExtractorInterface $metadataExtractor,
26
        private readonly ?ResourceNameCollectionFactoryInterface $decorated = null,
27
    ) {
28
    }
1,553✔
29

30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function create(): ResourceNameCollection
34
    {
35
        $classes = [];
2✔
36

37
        if ($this->decorated) {
2✔
38
            foreach ($this->decorated->create() as $resourceClass) {
2✔
39
                $classes[$resourceClass] = true;
2✔
40
            }
41
        }
42

43
        foreach ($this->metadataExtractor->getResources() as $resource) {
2✔
NEW
44
            $resourceClass = $resource->getClass();
×
45

NEW
46
            if (null === $resourceClass) {
×
NEW
47
                continue;
×
48
            }
49

NEW
50
            $classes[$resourceClass] = true;
×
51
        }
52

53
        return new ResourceNameCollection(array_keys($classes));
2✔
54
    }
55
}
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

© 2026 Coveralls, Inc