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

api-platform / core / 19438754788

17 Nov 2025 05:34PM UTC coverage: 0.0%. Remained the same
19438754788

push

github

soyuka
Merge 4.2

0 of 95 new or added lines in 28 files covered. (0.0%)

19 existing lines in 18 files now uncovered.

0 of 57020 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

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

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

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

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

NEW
57
        $request?->attributes->set('persisted_data', $persisted);
×
58

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