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

api-platform / core / 19164609113

07 Nov 2025 09:50AM UTC coverage: 0.0% (-24.0%) from 23.965%
19164609113

push

github

web-flow
chore: malformed json (#7512)

0 of 56687 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/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
final class ObjectMapper implements ObjectMapperInterface, ClearObjectMapInterface, ObjectMapperAwareInterface
21
{
22
    private ?\SplObjectStorage $objectMap = null;
23

24
    public function __construct(private ObjectMapperInterface $decorated)
25
    {
26
        if (null === $this->objectMap) {
×
27
            $this->objectMap = new \SplObjectStorage();
×
28
        }
29

30
        if ($this->decorated instanceof ObjectMapperAwareInterface) {
×
31
            $this->decorated = $this->decorated->withObjectMapper($this);
×
32
        }
33
    }
34

35
    public function map(object $source, object|string|null $target = null): object
36
    {
37
        if (!\is_object($target) && isset($this->objectMap[$source])) {
×
38
            $target = $this->objectMap[$source];
×
39
        }
40
        $mapped = $this->decorated->map($source, $target);
×
41
        $this->objectMap[$mapped] = $source;
×
42

43
        return $mapped;
×
44
    }
45

46
    public function clearObjectMap(): void
47
    {
48
        foreach ($this->objectMap as $k) {
×
49
            $this->objectMap->detach($k);
×
50
        }
51
    }
52

53
    public function withObjectMapper(ObjectMapperInterface $objectMapper): static
54
    {
55
        if (!$this->decorated instanceof ObjectMapperAwareInterface) {
×
56
            throw new RuntimeException(\sprintf('Given object mapper "%s" does not implements %s.', get_debug_type($this->decorated), ObjectMapperAwareInterface::class));
×
57
        }
58

59
        $this->decorated->withObjectMapper($objectMapper);
×
60

61
        return $this;
×
62
    }
63
}
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