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

api-platform / core / 15255731762

26 May 2025 01:55PM UTC coverage: 0.0% (-26.5%) from 26.526%
15255731762

Pull #7176

github

web-flow
Merge 66f6cf4d2 into 79edced67
Pull Request #7176: Merge 4.1

0 of 387 new or added lines in 28 files covered. (0.0%)

11394 existing lines in 372 files now uncovered.

0 of 51334 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/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

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

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

NEW
36
        $properties = $parentPropertyNameCollection ? array_flip(iterator_to_array($parentPropertyNameCollection)) : [];
×
37

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

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