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

api-platform / core / 15955912273

29 Jun 2025 01:51PM UTC coverage: 22.057% (-0.03%) from 22.082%
15955912273

Pull #7249

github

web-flow
Merge d9904d788 into a42034dc3
Pull Request #7249: chore: solve some phpstan issues

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

11540 existing lines in 372 files now uncovered.

11522 of 52237 relevant lines covered (22.06%)

11.08 hits per line

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

35.29
/src/Metadata/Resource/Factory/PhpFileResourceMetadataCollectionFactory.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\Operation;
18
use ApiPlatform\Metadata\Operations;
19
use ApiPlatform\Metadata\Resource\ResourceMetadataCollection;
20

21
final class PhpFileResourceMetadataCollectionFactory implements ResourceMetadataCollectionFactoryInterface
22
{
23
    use OperationDefaultsTrait;
24

25
    public function __construct(
26
        private readonly ResourceExtractorInterface $metadataExtractor,
27
        private readonly ?ResourceMetadataCollectionFactoryInterface $decorated = null,
28
    ) {
UNCOV
29
    }
291✔
30

31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function create(string $resourceClass): ResourceMetadataCollection
35
    {
UNCOV
36
        $resourceMetadataCollection = new ResourceMetadataCollection($resourceClass);
50✔
UNCOV
37
        if ($this->decorated) {
50✔
UNCOV
38
            $resourceMetadataCollection = $this->decorated->create($resourceClass);
50✔
39
        }
40

UNCOV
41
        foreach ($this->metadataExtractor->getResources() as $resource) {
50✔
42
            if ($resourceClass !== $resource->getClass()) {
×
43
                continue;
×
44
            }
45

46
            $shortName = (false !== $pos = strrpos($resourceClass, '\\')) ? substr($resourceClass, $pos + 1) : $resourceClass;
×
47
            $resource = $this->getResourceWithDefaults($resourceClass, $shortName, $resource);
×
48

49
            $operations = [];
×
50
            /** @var Operation $operation */
51
            foreach ($resource->getOperations() ?? new Operations() as $operation) {
×
52
                [$key, $operation] = $this->getOperationWithDefaults($resource, $operation);
×
53
                $operations[$key] = $operation;
×
54
            }
55

56
            if ($operations) {
×
57
                $resource = $resource->withOperations(new Operations($operations));
×
58
            }
59

60
            $resourceMetadataCollection[] = $resource;
×
61
        }
62

UNCOV
63
        return $resourceMetadataCollection;
50✔
64
    }
65
}
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