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

api-platform / core / 15023181448

14 May 2025 02:19PM UTC coverage: 0.0% (-8.4%) from 8.418%
15023181448

Pull #7139

github

web-flow
Merge 9f45709da into 1862d03b7
Pull Request #7139: refactor(symfony): remove obsolete option `validator.query-parameter-validation`

0 of 4 new or added lines in 1 file covered. (0.0%)

11266 existing lines in 366 files now uncovered.

0 of 50828 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/PropertySchemaLessThanRestriction.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\LessThan;
23

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

41
    public function supports(Constraint $constraint, ApiProperty $propertyMetadata): bool
42
    {
UNCOV
43
        if (!$constraint instanceof LessThan || !is_numeric($constraint->value)) {
×
UNCOV
44
            return false;
×
45
        }
46

UNCOV
47
        if (method_exists(PropertyInfoExtractor::class, 'getType')) {
×
UNCOV
48
            $type = $propertyMetadata->getExtraProperties()['nested_schema'] ?? false
×
49
                ? Type::int()
×
UNCOV
50
                : $propertyMetadata->getNativeType();
×
51

UNCOV
52
            return $type->isIdentifiedBy(TypeIdentifier::INT, TypeIdentifier::FLOAT);
×
53
        }
54

55
        $types = array_map(fn (LegacyType $type) => $type->getBuiltinType(), $propertyMetadata->getBuiltinTypes() ?? []);
×
56
        if ($propertyMetadata->getExtraProperties()['nested_schema'] ?? false) {
×
57
            $types = [LegacyType::BUILTIN_TYPE_INT];
×
58
        }
59

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