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

api-platform / core / 19337755357

13 Nov 2025 04:03PM UTC coverage: 0.0%. Remained the same
19337755357

push

github

soyuka
Merge 4.2

0 of 298 new or added lines in 18 files covered. (0.0%)

61 existing lines in 11 files now uncovered.

0 of 56962 relevant lines covered (0.0%)

0.0 hits per line

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

0.0
/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
use ApiPlatform\Metadata\Util\CamelCaseToSnakeCaseNameConverter;
21
use Psr\Log\LoggerInterface;
22
use Psr\Log\NullLogger;
23

24
final class PhpFileResourceMetadataCollectionFactory implements ResourceMetadataCollectionFactoryInterface
25
{
26
    use OperationDefaultsTrait;
27

28
    public function __construct(
29
        private readonly ResourceExtractorInterface $metadataExtractor,
30
        private readonly ?ResourceMetadataCollectionFactoryInterface $decorated = null,
31
        ?LoggerInterface $logger = null,
32
        array $defaults = [],
33
    ) {
NEW
34
        $this->logger = $logger ?? new NullLogger();
×
NEW
35
        $this->defaults = $defaults;
×
NEW
36
        $this->camelCaseToSnakeCaseNameConverter = new CamelCaseToSnakeCaseNameConverter();
×
37
    }
38

39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function create(string $resourceClass): ResourceMetadataCollection
43
    {
44
        $resourceMetadataCollection = new ResourceMetadataCollection($resourceClass);
×
45
        if ($this->decorated) {
×
46
            $resourceMetadataCollection = $this->decorated->create($resourceClass);
×
47
        }
48

49
        foreach ($this->metadataExtractor->getResources() as $resource) {
×
50
            if ($resourceClass !== $resource->getClass()) {
×
51
                continue;
×
52
            }
53

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

57
            $operations = [];
×
58
            /** @var Operation $operation */
59
            foreach ($resource->getOperations() ?? new Operations() as $operation) {
×
60
                [$key, $operation] = $this->getOperationWithDefaults($resource, $operation);
×
61
                $operations[$key] = $operation;
×
62
            }
63

64
            if ($operations) {
×
65
                $resource = $resource->withOperations(new Operations($operations));
×
66
            }
67

68
            $resourceMetadataCollection[] = $resource;
×
69
        }
70

71
        return $resourceMetadataCollection;
×
72
    }
73
}
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