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

api-platform / core / 13203240131

07 Feb 2025 03:47PM UTC coverage: 7.286%. Remained the same
13203240131

push

github

soyuka
docs: v4.0.17

12429 of 170587 relevant lines covered (7.29%)

11.98 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
    ) {
34
    }
709✔
35

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

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

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

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

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

64
        return new ResourceNameCollection(array_keys($classes));
1✔
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