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

api-platform / core / 17545966872

08 Sep 2025 09:18AM UTC coverage: 22.312% (-0.3%) from 22.604%
17545966872

push

github

web-flow
fix(metadata): wrong method name in resource mutator

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

12092 existing lines in 401 files now uncovered.

11916 of 53406 relevant lines covered (22.31%)

13.09 hits per line

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

100.0
/src/JsonLd/JsonStreamer/WritePropertyMetadataLoader.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;
15

16
use ApiPlatform\Hydra\Collection;
17
use ApiPlatform\Hydra\IriTemplate;
18
use ApiPlatform\Metadata\ResourceClassResolverInterface;
19
use ApiPlatform\Metadata\Util\TypeHelper;
20
use Symfony\Component\JsonStreamer\Mapping\PropertyMetadata;
21
use Symfony\Component\JsonStreamer\Mapping\PropertyMetadataLoaderInterface;
22
use Symfony\Component\TypeInfo\Type;
23

24
final class WritePropertyMetadataLoader implements PropertyMetadataLoaderInterface
25
{
26
    public function __construct(
27
        private readonly PropertyMetadataLoaderInterface $loader,
28
        private readonly ResourceClassResolverInterface $resourceClassResolver,
29
    ) {
UNCOV
30
    }
312✔
31

32
    public function load(string $className, array $options = [], array $context = []): array
33
    {
UNCOV
34
        $properties = $this->loader->load($className, $options, $context);
2✔
35

UNCOV
36
        if (IriTemplate::class === $className) {
2✔
UNCOV
37
            $properties['template'] = new PropertyMetadata(
1✔
UNCOV
38
                'template',
1✔
UNCOV
39
                Type::string(),
1✔
UNCOV
40
                ['api_platform.hydra.json_streamer.write.value_transformer.template'],
1✔
UNCOV
41
            );
1✔
42

UNCOV
43
            return $properties;
1✔
44
        }
45

UNCOV
46
        if (Collection::class !== $className && !$this->resourceClassResolver->isResourceClass($className)) {
2✔
UNCOV
47
            return $properties;
1✔
48
        }
49

UNCOV
50
        $properties['@id'] = new PropertyMetadata(
2✔
UNCOV
51
            'id', // virtual property
2✔
UNCOV
52
            Type::mixed(), // virtual property
2✔
UNCOV
53
            ['api_platform.jsonld.json_streamer.write.value_transformer.iri'],
2✔
UNCOV
54
        );
2✔
55

UNCOV
56
        $properties['@type'] = new PropertyMetadata(
2✔
UNCOV
57
            'id', // virtual property
2✔
UNCOV
58
            Type::mixed(), // virtual property
2✔
UNCOV
59
            ['api_platform.jsonld.json_streamer.write.value_transformer.type'],
2✔
UNCOV
60
        );
2✔
61

UNCOV
62
        $originalClassName = TypeHelper::getClassName($context['original_type']);
2✔
63

UNCOV
64
        if (Collection::class === $originalClassName || ($this->resourceClassResolver->isResourceClass($originalClassName) && !isset($context['generated_classes'][Collection::class]))) {
2✔
UNCOV
65
            $properties['@context'] = new PropertyMetadata(
2✔
UNCOV
66
                'id', // virual property
2✔
UNCOV
67
                Type::string(), // virtual property
2✔
UNCOV
68
                ['api_platform.jsonld.json_streamer.write.value_transformer.context'],
2✔
UNCOV
69
            );
2✔
70
        }
71

UNCOV
72
        return $properties;
2✔
73
    }
74
}
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