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

api-platform / core / 10903050455

17 Sep 2024 12:29PM UTC coverage: 7.684% (+0.7%) from 6.96%
10903050455

push

github

web-flow
fix: swagger ui with route identifier (#6616)

2 of 6 new or added lines in 6 files covered. (33.33%)

9000 existing lines in 286 files now uncovered.

12668 of 164863 relevant lines covered (7.68%)

22.93 hits per line

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

95.24
/src/Metadata/Property/Factory/PropertyInfoPropertyMetadataFactory.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\Exception\PropertyNotFoundException;
18
use Doctrine\Common\Collections\ArrayCollection;
19
use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface;
20
use Symfony\Component\PropertyInfo\Type;
21

22
/**
23
 * PropertyInfo metadata loader decorator.
24
 *
25
 * @author Kévin Dunglas <dunglas@gmail.com>
26
 */
27
final class PropertyInfoPropertyMetadataFactory implements PropertyMetadataFactoryInterface
28
{
29
    public function __construct(private readonly PropertyInfoExtractorInterface $propertyInfo, private readonly ?PropertyMetadataFactoryInterface $decorated = null)
30
    {
UNCOV
31
    }
2,258✔
32

33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function create(string $resourceClass, string $property, array $options = []): ApiProperty
37
    {
UNCOV
38
        if (null === $this->decorated) {
532✔
39
            $propertyMetadata = new ApiProperty();
×
40
        } else {
41
            try {
UNCOV
42
                $propertyMetadata = $this->decorated->create($resourceClass, $property, $options);
532✔
UNCOV
43
            } catch (PropertyNotFoundException) {
529✔
UNCOV
44
                $propertyMetadata = new ApiProperty();
529✔
45
            }
46
        }
47

UNCOV
48
        if (!$propertyMetadata->getBuiltinTypes()) {
532✔
UNCOV
49
            $types = $this->propertyInfo->getTypes($resourceClass, $property, $options) ?? [];
532✔
50

UNCOV
51
            foreach ($types as $i => $type) {
532✔
52
                // Temp fix for https://github.com/symfony/symfony/pull/52699
UNCOV
53
                if (ArrayCollection::class === $type->getClassName()) {
484✔
UNCOV
54
                    $types[$i] = new Type($type->getBuiltinType(), $type->isNullable(), $type->getClassName(), true, $type->getCollectionKeyTypes(), $type->getCollectionValueTypes());
9✔
55
                }
56
            }
57

UNCOV
58
            $propertyMetadata = $propertyMetadata->withBuiltinTypes($types);
532✔
59
        }
60

UNCOV
61
        if (null === $propertyMetadata->getDescription() && null !== $description = $this->propertyInfo->getShortDescription($resourceClass, $property, $options)) {
532✔
UNCOV
62
            $propertyMetadata = $propertyMetadata->withDescription($description);
180✔
63
        }
64

UNCOV
65
        if (null === $propertyMetadata->isReadable() && null !== $readable = $this->propertyInfo->isReadable($resourceClass, $property, $options)) {
532✔
UNCOV
66
            $propertyMetadata = $propertyMetadata->withReadable($readable);
529✔
67
        }
68

UNCOV
69
        if (null === $propertyMetadata->isWritable() && null !== $writable = $this->propertyInfo->isWritable($resourceClass, $property, $options)) {
532✔
UNCOV
70
            $propertyMetadata = $propertyMetadata->withWritable($writable);
529✔
71
        }
72

73
        /* @phpstan-ignore-next-line */
UNCOV
74
        if (null === $propertyMetadata->isInitializable() && null !== $initializable = $this->propertyInfo->isInitializable($resourceClass, $property, $options)) {
532✔
UNCOV
75
            $propertyMetadata = $propertyMetadata->withInitializable($initializable);
532✔
76
        }
77

UNCOV
78
        return $propertyMetadata;
532✔
79
    }
80
}
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