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

api-platform / core / 17487610263

05 Sep 2025 08:12AM UTC coverage: 22.608% (+0.3%) from 22.319%
17487610263

push

github

web-flow
chore: remove @experimental flag from parameters (#7357)

12049 of 53296 relevant lines covered (22.61%)

26.21 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
    ) {
30
    }
574✔
31

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

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

43
            return $properties;
2✔
44
        }
45

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

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

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

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

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

72
        return $properties;
4✔
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