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

api-platform / core / 14854709983

06 May 2025 08:07AM UTC coverage: 8.457% (-0.002%) from 8.459%
14854709983

Pull #7122

github

web-flow
Merge 6b1cde96f into f55606b01
Pull Request #7122: Cherry picks from main (deprecations)

0 of 35 new or added lines in 9 files covered. (0.0%)

2157 existing lines in 159 files now uncovered.

13397 of 158416 relevant lines covered (8.46%)

22.88 hits per line

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

69.23
/src/Metadata/Resource/Factory/ConcernsResourceNameCollectionFactory.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\IsApiResource;
17
use ApiPlatform\Metadata\Resource\ResourceNameCollection;
18
use ApiPlatform\Metadata\Util\ReflectionClassRecursiveIterator;
19

20
/**
21
 * Creates a resource name collection from {@see IsApiResource} concerns.
22
 *
23
 * @author Kévin Dunglas <kevin@dunglas.dev>
24
 */
25
final class ConcernsResourceNameCollectionFactory implements ResourceNameCollectionFactoryInterface
26
{
27
    /**
28
     * @param string[] $paths
29
     */
30
    public function __construct(
31
        private readonly array $paths,
32
        private readonly ?ResourceNameCollectionFactoryInterface $decorated = null,
33
    ) {
UNCOV
34
    }
1,553✔
35

36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function create(): ResourceNameCollection
40
    {
UNCOV
41
        $classes = [];
2✔
42

UNCOV
43
        if ($this->decorated) {
2✔
UNCOV
44
            foreach ($this->decorated->create() as $resourceClass) {
2✔
UNCOV
45
                $classes[$resourceClass] = true;
2✔
46
            }
47
        }
48

UNCOV
49
        foreach (ReflectionClassRecursiveIterator::getReflectionClassesFromDirectories($this->paths) as $className => $reflectionClass) {
2✔
UNCOV
50
            if (!$reflectionClass->hasMethod('apiResource')) {
2✔
UNCOV
51
                continue;
2✔
52
            }
53

54
            $m = $reflectionClass->getMethod('apiResource');
×
55

56
            if (
57
                $m->isPublic()
×
58
                && $m->isStatic()
×
59
            ) {
60
                $classes[$className] = true;
×
61
            }
62
        }
63

UNCOV
64
        return new ResourceNameCollection(array_keys($classes));
2✔
65
    }
66
}
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