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

api-platform / core / 15255731762

26 May 2025 01:55PM UTC coverage: 0.0% (-26.5%) from 26.526%
15255731762

Pull #7176

github

web-flow
Merge 66f6cf4d2 into 79edced67
Pull Request #7176: Merge 4.1

0 of 387 new or added lines in 28 files covered. (0.0%)

11394 existing lines in 372 files now uncovered.

0 of 51334 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/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
    }
×
30

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

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

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

UNCOV
45
            foreach ($operations as $operationName => $operation) {
×
UNCOV
46
                if ($operation->getName()) {
×
UNCOV
47
                    continue;
×
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);
×
60
        }
61

UNCOV
62
        return $resourceMetadataCollection;
×
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