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

api-platform / core / 20847864477

09 Jan 2026 09:47AM UTC coverage: 29.1% (+0.005%) from 29.095%
20847864477

Pull #7649

github

web-flow
Merge b342dd5db into d640d106b
Pull Request #7649: feat(validator): uuid/ulid parameter validation

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

15050 existing lines in 491 files now uncovered.

16996 of 58406 relevant lines covered (29.1%)

81.8 hits per line

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

100.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\HttpFoundation\Response;
19
use Symfony\Component\ObjectMapper\ObjectMapperInterface;
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
    ) {
UNCOV
33
    }
2,357✔
34

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

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

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

59
        // in some cases (delete operation), the decoration may return a null object
UNCOV
60
        if (null === $persisted) {
6✔
UNCOV
61
            return $persisted;
2✔
62
        }
63

UNCOV
64
        $request?->attributes->set('persisted_data', $persisted);
6✔
65

66
        // return the Resource representation of the persisted entity
UNCOV
67
        return $this->objectMapper->map(
6✔
68
            // persist the entity
UNCOV
69
            $persisted,
6✔
UNCOV
70
            $operation->getClass()
6✔
UNCOV
71
        );
6✔
72
    }
73
}
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

© 2026 Coveralls, Inc