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

api-platform / core / 10797021570

10 Sep 2024 04:49PM UTC coverage: 7.679% (+0.02%) from 7.659%
10797021570

push

github

soyuka
fix(laravel): parameter fixes and tests

32 of 49 new or added lines in 6 files covered. (65.31%)

2574 existing lines in 81 files now uncovered.

12619 of 164324 relevant lines covered (7.68%)

23.18 hits per line

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

91.67
/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
    }
2,252✔
35

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

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

UNCOV
49
        foreach (ReflectionClassRecursiveIterator::getReflectionClassesFromDirectories($this->paths) as $className => $reflectionClass) {
3✔
50
            if (
UNCOV
51
                $reflectionClass->hasMethod('apiResource')
3✔
UNCOV
52
                && ($m = $reflectionClass->getMethod('apiResource'))
3✔
UNCOV
53
                && $m->isPublic()
3✔
UNCOV
54
                && $m->isStatic()
3✔
55
            ) {
56
                $classes[$className] = true;
×
57
            }
58
        }
59

UNCOV
60
        return new ResourceNameCollection(array_keys($classes));
3✔
61
    }
62
}
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