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

api-platform / core / 13814792797

12 Mar 2025 03:09PM UTC coverage: 5.889% (-1.4%) from 7.289%
13814792797

Pull #7012

github

web-flow
Merge 199d44919 into 284937039
Pull Request #7012: doc: comment typo in ApiResource.php

10048 of 170615 relevant lines covered (5.89%)

5.17 hits per line

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

0.0
/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
    }
×
35

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

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

49
        foreach (ReflectionClassRecursiveIterator::getReflectionClassesFromDirectories($this->paths) as $className => $reflectionClass) {
×
50
            if (!$reflectionClass->hasMethod('apiResource')) {
×
51
                continue;
×
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));
×
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