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

api-platform / core / 19328344137

13 Nov 2025 10:24AM UTC coverage: 24.691%. Remained the same
19328344137

Pull #7531

github

web-flow
Merge e7a6002b4 into a5c44624d
Pull Request #7531: fix(symfony): object mapper compatibility

4 of 10 new or added lines in 1 file covered. (40.0%)

1 existing line in 1 file now uncovered.

14195 of 57490 relevant lines covered (24.69%)

26.9 hits per line

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

36.36
/src/State/ObjectMapper/ObjectMapper.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\ObjectMapper;
15

16
use ApiPlatform\Metadata\Exception\RuntimeException;
17
use Symfony\Component\ObjectMapper\ObjectMapperAwareInterface;
18
use Symfony\Component\ObjectMapper\ObjectMapperInterface;
19

20
if (class_exists(ObjectMapperAwareInterface::class)) {
2✔
21
    final class ObjectMapper implements ObjectMapperInterface
22
    {
23
        public function __construct(private ObjectMapperInterface $decorated)
24
        {
UNCOV
25
        }
×
26

27
        public function map(object $source, object|string|null $target = null): object
28
        {
NEW
29
            return $this->decorated->map($source, $target);
×
30
        }
31
    }
32
} else {
33
    final class ObjectMapper implements ObjectMapperInterface, ObjectMapperAwareInterface
34
    {
35
        public function __construct(private ObjectMapperInterface $decorated)
36
        {
37
            if ($this->decorated instanceof ObjectMapperAwareInterface) {
718✔
38
                $this->decorated = $this->decorated->withObjectMapper($this);
718✔
39
            }
40
        }
41

42
        public function map(object $source, object|string|null $target = null): object
43
        {
44
            return $this->decorated->map($source, $target);
10✔
45
        }
46

47
        public function withObjectMapper(ObjectMapperInterface $objectMapper): static
48
        {
NEW
49
            $s = clone $this;
×
50

NEW
51
            if (!$s->decorated instanceof ObjectMapperAwareInterface) {
×
NEW
52
                throw new RuntimeException(\sprintf('Given object mapper "%s" does not implements %s.', get_debug_type($this->decorated), ObjectMapperAwareInterface::class));
×
53
            }
54

NEW
55
            $s->decorated->withObjectMapper($objectMapper);
×
56

NEW
57
            return $s;
×
58
        }
59
    }
60
}
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