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

api-platform / core / 18089937549

29 Sep 2025 07:56AM UTC coverage: 21.764% (-0.3%) from 22.093%
18089937549

Pull #7416

github

web-flow
Merge 061bcc790 into abe0438be
Pull Request #7416: fix(laravel): serializer attributes on Eloquent methods

0 of 151 new or added lines in 11 files covered. (0.0%)

5028 existing lines in 173 files now uncovered.

11889 of 54626 relevant lines covered (21.76%)

25.32 hits per line

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

0.0
/src/Elasticsearch/Serializer/ItemNormalizer.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\Elasticsearch\Serializer;
15

16
use Symfony\Component\Serializer\Exception\LogicException;
17
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
18
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
19
use Symfony\Component\Serializer\SerializerAwareInterface;
20
use Symfony\Component\Serializer\SerializerInterface;
21

22
/**
23
 * Item normalizer decorator that prevents {@see \ApiPlatform\Serializer\ItemNormalizer}
24
 * from taking over for the {@see DocumentNormalizer::FORMAT} format because of priorities.
25
 *
26
 * @experimental
27
 */
28
final class ItemNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface
29
{
30
    public const FORMAT = 'elasticsearch';
31

32
    public function __construct(private readonly NormalizerInterface $decorated)
33
    {
34
    }
×
35

36
    /**
37
     * {@inheritdoc}
38
     *
39
     * @throws LogicException
40
     */
41
    public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
42
    {
43
        if (!$this->decorated instanceof DenormalizerInterface) {
×
44
            throw new LogicException(\sprintf('The decorated normalizer must be an instance of "%s".', DenormalizerInterface::class));
×
45
        }
46

47
        return $this->decorated->denormalize($data, $type, $format, $context);
×
48
    }
49

50
    /**
51
     * {@inheritdoc}
52
     *
53
     * @throws LogicException
54
     */
55
    public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool
56
    {
57
        if (!$this->decorated instanceof DenormalizerInterface) {
×
58
            throw new LogicException(\sprintf('The decorated normalizer must be an instance of "%s".', DenormalizerInterface::class));
×
59
        }
60

61
        return DocumentNormalizer::FORMAT !== $format && $this->decorated->supportsDenormalization($data, $type, $format, $context);
×
62
    }
63

64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function normalize(mixed $object, ?string $format = null, array $context = []): \ArrayObject|array|string|int|float|bool|null
68
    {
69
        return $this->decorated->normalize($object, $format, $context);
×
70
    }
71

72
    /**
73
     * {@inheritdoc}
74
     */
75
    public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
76
    {
77
        return DocumentNormalizer::FORMAT !== $format && $this->decorated->supportsNormalization($data, $format);
×
78
    }
79

80
    /**
81
     * @param string|null $format
82
     */
83
    public function getSupportedTypes($format): array
84
    {
UNCOV
85
        return DocumentNormalizer::FORMAT !== $format ? $this->decorated->getSupportedTypes($format) : [];
×
86
    }
87

88
    /**
89
     * {@inheritdoc}
90
     *
91
     * @throws LogicException
92
     */
93
    public function setSerializer(SerializerInterface $serializer): void
94
    {
UNCOV
95
        if (!$this->decorated instanceof SerializerAwareInterface) {
×
96
            throw new LogicException(\sprintf('The decorated normalizer must be an instance of "%s".', SerializerAwareInterface::class));
×
97
        }
98

UNCOV
99
        $this->decorated->setSerializer($serializer);
×
100
    }
101
}
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