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

api-platform / core / 16531587208

25 Jul 2025 09:05PM UTC coverage: 0.0% (-22.1%) from 22.07%
16531587208

Pull #7225

github

web-flow
Merge 23f449a58 into 02a764950
Pull Request #7225: feat: json streamer

0 of 294 new or added lines in 31 files covered. (0.0%)

11514 existing lines in 375 files now uncovered.

0 of 51976 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/IriValueTransformer.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\CollectionOperationInterface;
18
use ApiPlatform\Metadata\Exception\RuntimeException;
19
use ApiPlatform\Metadata\IriConverterInterface;
20
use ApiPlatform\Metadata\UrlGeneratorInterface;
21
use Symfony\Component\JsonStreamer\ValueTransformer\ValueTransformerInterface;
22
use Symfony\Component\TypeInfo\Type;
23

24
final class IriValueTransformer implements ValueTransformerInterface
25
{
26
    public function __construct(
27
        private readonly IriConverterInterface $iriConverter,
28
    ) {
NEW
29
    }
×
30

31
    public function transform(mixed $value, array $options = []): mixed
32
    {
NEW
33
        if (!isset($options['operation'])) {
×
NEW
34
            throw new RuntimeException('Operation is not defined');
×
35
        }
36

NEW
37
        if ($options['_current_object'] instanceof Collection) {
×
NEW
38
            return $this->iriConverter->getIriFromResource($options['operation']->getClass(), UrlGeneratorInterface::ABS_PATH, $options['operation']);
×
39
        }
40

NEW
41
        return $this->iriConverter->getIriFromResource(
×
NEW
42
            $options['_current_object'],
×
NEW
43
            UrlGeneratorInterface::ABS_PATH,
×
NEW
44
            $options['operation'] instanceof CollectionOperationInterface ? null : $options['operation'],
×
NEW
45
        );
×
46
    }
47

48
    public static function getStreamValueType(): Type
49
    {
NEW
50
        return Type::string();
×
51
    }
52
}
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