• 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/Provider/ObjectMapperProvider.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\Provider;
15

16
use ApiPlatform\Metadata\Operation;
17
use ApiPlatform\Metadata\Util\CloneTrait;
18
use ApiPlatform\State\Pagination\MappedObjectPaginator;
19
use ApiPlatform\State\Pagination\PaginatorInterface;
20
use ApiPlatform\State\ProviderInterface;
21
use Symfony\Component\ObjectMapper\ObjectMapperInterface;
22

23
/**
24
 * @implements ProviderInterface<object>
25
 */
26
final class ObjectMapperProvider implements ProviderInterface
27
{
28
    use CloneTrait;
29

30
    /**
31
     * @param ProviderInterface<object> $decorated
32
     */
33
    public function __construct(
34
        private readonly ?ObjectMapperInterface $objectMapper,
35
        private readonly ProviderInterface $decorated,
36
    ) {
UNCOV
37
    }
2,416✔
38

39
    public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
40
    {
UNCOV
41
        $data = $this->decorated->provide($operation, $uriVariables, $context);
2,075✔
UNCOV
42
        $class = $operation->getOutput()['class'] ?? $operation->getClass();
2,072✔
43

UNCOV
44
        if (!$this->objectMapper || !$operation->canMap()) {
2,072✔
UNCOV
45
            return $data;
2,044✔
46
        }
47

UNCOV
48
        if (!\is_object($data) && !\is_array($data)) {
30✔
UNCOV
49
            return $data;
4✔
50
        }
51

UNCOV
52
        $request = $context['request'] ?? null;
28✔
UNCOV
53
        $request?->attributes->set('mapped_data', $data);
28✔
54

UNCOV
55
        if ($data instanceof PaginatorInterface) {
28✔
UNCOV
56
            $data = new MappedObjectPaginator(
14✔
UNCOV
57
                iterator_to_array($data),
14✔
UNCOV
58
                $this->objectMapper,
14✔
UNCOV
59
                $class,
14✔
UNCOV
60
                $data->getTotalItems(),
14✔
UNCOV
61
                $data->getCurrentPage(),
14✔
UNCOV
62
                $data->getLastPage(),
14✔
UNCOV
63
                $data->getItemsPerPage(),
14✔
UNCOV
64
            );
14✔
UNCOV
65
        } elseif (\is_array($data)) {
18✔
UNCOV
66
            foreach ($data as &$v) {
6✔
UNCOV
67
                if (\is_object($v)) {
4✔
UNCOV
68
                    $v = $this->objectMapper->map($v, $class);
4✔
69
                }
70
            }
71
        } else {
UNCOV
72
            $data = $this->objectMapper->map($data, $class);
12✔
73
        }
74

UNCOV
75
        $request?->attributes->set('data', $data);
28✔
UNCOV
76
        $request?->attributes->set('previous_data', $this->clone($data));
28✔
77

UNCOV
78
        return $data;
28✔
79
    }
80
}
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