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

api-platform / core / 19799380020

30 Nov 2025 01:09PM UTC coverage: 0.0%. Remained the same
19799380020

push

github

soyuka
Merge 4.2

0 of 306 new or added lines in 35 files covered. (0.0%)

22 existing lines in 15 files now uncovered.

0 of 57173 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/State/Processor/ObjectMapperProcessor.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\State\Processor;
15

16
use ApiPlatform\Metadata\Operation;
17
use ApiPlatform\State\ProcessorInterface;
18
use Symfony\Component\ObjectMapper\ObjectMapperInterface;
19
use Symfony\Component\HttpFoundation\Response;
20

21
/**
22
 * @implements ProcessorInterface<mixed,mixed>
23
 */
24
final class ObjectMapperProcessor implements ProcessorInterface
25
{
26
    /**
27
     * @param ProcessorInterface<mixed,mixed> $decorated
28
     */
29
    public function __construct(
30
        private readonly ?ObjectMapperInterface $objectMapper,
31
        private readonly ProcessorInterface $decorated,
32
    ) {
33
    }
×
34

35
    public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): object|array|null
36
    {
37
        $class = $operation->getInput()['class'] ?? $operation->getClass();
×
38

39
        if (
NEW
40
            $data instanceof Response
×
NEW
41
            || !$this->objectMapper
×
42
            || !$operation->canWrite()
×
43
            || null === $data
×
44
            || !is_a($data, $class, true)
×
45
            || !$operation->canMap()
×
46
        ) {
47
            return $this->decorated->process($data, $operation, $uriVariables, $context);
×
48
        }
49

50
        $request = $context['request'] ?? null;
×
51
        $persisted = $this->decorated->process(
×
52
            // maps the Resource to an Entity
53
            $this->objectMapper->map($data, $request?->attributes->get('mapped_data')),
×
54
            $operation,
×
55
            $uriVariables,
×
56
            $context,
×
57
        );
×
58

59
        $request?->attributes->set('persisted_data', $persisted);
×
60

61
        // return the Resource representation of the persisted entity
62
        return $this->objectMapper->map(
×
63
            // persist the entity
64
            $persisted,
×
65
            $operation->getClass()
×
66
        );
×
67
    }
68
}
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