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

api-platform / core / 15133993414

20 May 2025 09:30AM UTC coverage: 26.313% (-1.2%) from 27.493%
15133993414

Pull #7161

github

web-flow
Merge e2c03d45f into 5459ba375
Pull Request #7161: fix(metadata): infer parameter string type from schema

0 of 2 new or added lines in 1 file covered. (0.0%)

11019 existing lines in 363 files now uncovered.

12898 of 49018 relevant lines covered (26.31%)

34.33 hits per line

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

68.75
/src/Metadata/Resource/Factory/OperationNameResourceMetadataCollectionFactory.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\Resource\ResourceMetadataCollection;
17

18
/**
19
 * Creates a resource metadata from {@see Resource} annotations.
20
 *
21
 * @author Antoine Bluchet <soyuka@gmail.com>
22
 */
23
final class OperationNameResourceMetadataCollectionFactory implements ResourceMetadataCollectionFactoryInterface
24
{
25
    use OperationDefaultsTrait;
26

27
    public function __construct(private readonly ?ResourceMetadataCollectionFactoryInterface $decorated = null)
28
    {
UNCOV
29
    }
978✔
30

31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function create(string $resourceClass): ResourceMetadataCollection
35
    {
UNCOV
36
        $resourceMetadataCollection = new ResourceMetadataCollection($resourceClass);
69✔
37

UNCOV
38
        if ($this->decorated) {
69✔
UNCOV
39
            $resourceMetadataCollection = $this->decorated->create($resourceClass);
69✔
40
        }
41

UNCOV
42
        foreach ($resourceMetadataCollection as $i => $resource) {
69✔
UNCOV
43
            $operations = $resource->getOperations();
65✔
44

UNCOV
45
            foreach ($operations as $operationName => $operation) {
65✔
UNCOV
46
                if ($operation->getName()) {
65✔
UNCOV
47
                    continue;
65✔
48
                }
49

50
                if ($operation->getRouteName()) {
×
51
                    $operations->add($operationName, $operation->withName($operation->getRouteName()));
×
52
                    continue;
×
53
                }
54

55
                $newOperationName = $this->getDefaultOperationName($operation, $resourceClass);
×
56
                $operations->remove($operationName)->add($newOperationName, $operation->withName($newOperationName));
×
57
            }
58

UNCOV
59
            $resourceMetadataCollection[$i] = $resource->withOperations($operations);
65✔
60
        }
61

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