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

api-platform / core / 16531587208

25 Jul 2025 09:05PM UTC coverage: 0.0% (-22.1%) from 22.07%
16531587208

Pull #7225

github

web-flow
Merge 23f449a58 into 02a764950
Pull Request #7225: feat: json streamer

0 of 294 new or added lines in 31 files covered. (0.0%)

11514 existing lines in 375 files now uncovered.

0 of 51976 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/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaRangeRestriction.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\Symfony\Validator\Metadata\Property\Restriction;
15

16
use ApiPlatform\Metadata\ApiProperty;
17
use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
18
use Symfony\Component\PropertyInfo\Type as LegacyType;
19
use Symfony\Component\TypeInfo\Type;
20
use Symfony\Component\TypeInfo\TypeIdentifier;
21
use Symfony\Component\Validator\Constraint;
22
use Symfony\Component\Validator\Constraints\Range;
23

24
/**
25
 * @author Tomas Norkūnas <norkunas.tom@gmail.com>
26
 */
27
final class PropertySchemaRangeRestriction implements PropertySchemaRestrictionMetadataInterface
28
{
29
    /**
30
     * {@inheritdoc}
31
     *
32
     * @param Range $constraint
33
     */
34
    public function create(Constraint $constraint, ApiProperty $propertyMetadata): array
35
    {
UNCOV
36
        $restriction = [];
×
37

UNCOV
38
        if (isset($constraint->min) && is_numeric($constraint->min)) {
×
UNCOV
39
            $restriction['minimum'] = $constraint->min;
×
40
        }
41

UNCOV
42
        if (isset($constraint->max) && is_numeric($constraint->max)) {
×
UNCOV
43
            $restriction['maximum'] = $constraint->max;
×
44
        }
45

UNCOV
46
        return $restriction;
×
47
    }
48

49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function supports(Constraint $constraint, ApiProperty $propertyMetadata): bool
53
    {
UNCOV
54
        if (!$constraint instanceof Range) {
×
UNCOV
55
            return false;
×
56
        }
57

UNCOV
58
        if (method_exists(PropertyInfoExtractor::class, 'getType')) {
×
UNCOV
59
            $type = $propertyMetadata->getExtraProperties()['nested_schema'] ?? false
×
60
                ? Type::int()
×
UNCOV
61
                : $propertyMetadata->getNativeType();
×
62

UNCOV
63
            return $type->isIdentifiedBy(TypeIdentifier::INT, TypeIdentifier::FLOAT);
×
64
        }
65

66
        $types = array_map(fn (LegacyType $type) => $type->getBuiltinType(), $propertyMetadata->getBuiltinTypes() ?? []);
×
67
        if ($propertyMetadata->getExtraProperties()['nested_schema'] ?? false) {
×
68
            $types = [LegacyType::BUILTIN_TYPE_INT];
×
69
        }
70

71
        return \count($types) > 0 && \count(array_intersect($types, [LegacyType::BUILTIN_TYPE_INT, LegacyType::BUILTIN_TYPE_FLOAT])) > 0;
×
72
    }
73
}
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