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

api-platform / core / 17327553156

29 Aug 2025 03:13PM UTC coverage: 22.588% (-0.03%) from 22.622%
17327553156

push

github

web-flow
fix(laravel): serialization issue with camelCase relation (#7356)

fixes #7344

0 of 76 new or added lines in 9 files covered. (0.0%)

11415 existing lines in 372 files now uncovered.

11181 of 49499 relevant lines covered (22.59%)

23.68 hits per line

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

0.0
/src/Metadata/Property/Factory/ClassLevelAttributePropertyNameCollectionFactory.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\Metadata\Property\Factory;
15

16
use ApiPlatform\Metadata\ApiProperty;
17
use ApiPlatform\Metadata\Property\PropertyNameCollection;
18
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
19

20
/**
21
 * Gathers "virtual" properties created using the ApiProperty attribute at class level.
22
 */
23
final class ClassLevelAttributePropertyNameCollectionFactory implements PropertyNameCollectionFactoryInterface
24
{
25
    public function __construct(
26
        private readonly ?PropertyNameCollectionFactoryInterface $decorated = null,
27
        private readonly ?NameConverterInterface $nameConverter = null,
28
    ) {
29
    }
×
30

31
    public function create(string $resourceClass, array $options = []): PropertyNameCollection
32
    {
33
        $parentPropertyNameCollection = $this->decorated?->create($resourceClass, $options);
×
34
        if (!class_exists($resourceClass)) {
×
35
            return $parentPropertyNameCollection ?? new PropertyNameCollection();
×
36
        }
37

38
        $properties = $parentPropertyNameCollection ? array_flip(iterator_to_array($parentPropertyNameCollection)) : [];
×
39

40
        $refl = new \ReflectionClass($resourceClass);
×
41
        $attributes = $refl->getAttributes(ApiProperty::class);
×
42
        foreach ($attributes as $attribute) {
×
43
            $instance = $attribute->newInstance();
×
44
            if ($property = $instance->getProperty()) {
×
NEW
45
                $properties[$this->nameConverter?->denormalize($property) ?? $property] = true;
×
46
            }
47
        }
48

49
        return new PropertyNameCollection(array_keys($properties));
×
50
    }
51
}
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