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

api-platform / core / 17585586101

09 Sep 2025 02:16PM UTC coverage: 0.0% (-22.6%) from 22.592%
17585586101

push

github

web-flow
fix(state): transform uri variable using ReadLinkParameterProvider (#7375)

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

12247 existing lines in 411 files now uncovered.

0 of 52798 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/JsonLd/JsonStreamer/ValueTransformer/TypeValueTransformer.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\JsonLd\JsonStreamer\ValueTransformer;
15

16
use ApiPlatform\Hydra\Collection;
17
use ApiPlatform\Metadata\Exception\RuntimeException;
18
use ApiPlatform\Metadata\HttpOperation;
19
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
20
use ApiPlatform\Metadata\ResourceClassResolverInterface;
21
use Symfony\Component\JsonStreamer\ValueTransformer\ValueTransformerInterface;
22
use Symfony\Component\TypeInfo\Type;
23

24
final class TypeValueTransformer implements ValueTransformerInterface
25
{
26
    public function __construct(
27
        private readonly ResourceClassResolverInterface $resourceClassResolver,
28
        private readonly ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory,
29
    ) {
UNCOV
30
    }
×
31

32
    public function transform(mixed $value, array $options = []): mixed
33
    {
UNCOV
34
        if ($options['_current_object'] instanceof Collection) {
×
UNCOV
35
            return 'Collection';
×
36
        }
37

UNCOV
38
        $dataClass = isset($options['data']) && \is_object($options['data']) ? $options['data']::class : null;
×
UNCOV
39
        if (($currentClass = $options['_current_object']::class) === $dataClass) {
×
UNCOV
40
            if (!isset($options['operation'])) {
×
41
                throw new RuntimeException('Operation is not defined');
×
42
            }
43

UNCOV
44
            return $this->getOperationType($options['operation']);
×
45
        }
46

UNCOV
47
        if (!$this->resourceClassResolver->isResourceClass($currentClass)) {
×
48
            return null;
×
49
        }
50

51
        /** @var HttpOperation $op */
UNCOV
52
        $op = $this->resourceMetadataCollectionFactory->create($currentClass)->getOperation(httpOperation: true);
×
53

UNCOV
54
        return $this->getOperationType($op);
×
55
    }
56

57
    public static function getStreamValueType(): Type
58
    {
59
        return Type::string();
×
60
    }
61

62
    private function getOperationType(HttpOperation $operation): array|string
63
    {
UNCOV
64
        if (($t = $operation->getTypes()) && 1 === \count($t)) {
×
UNCOV
65
            return $operation->getTypes()[0];
×
66
        }
67

UNCOV
68
        return $t ?: $operation->getShortname();
×
69
    }
70
}
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

© 2026 Coveralls, Inc