• 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/PropertySchemaLengthRestriction.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\Length;
23

24
/**
25
 * Class PropertySchemaLengthRestrictions.
26
 *
27
 * @author Andrii Penchuk penja7@gmail.com
28
 */
29
class PropertySchemaLengthRestriction implements PropertySchemaRestrictionMetadataInterface
30
{
31
    /**
32
     * {@inheritdoc}
33
     *
34
     * @param Length $constraint
35
     */
36
    public function create(Constraint $constraint, ApiProperty $propertyMetadata): array
37
    {
38
        $restriction = [];
×
39

40
        if (isset($constraint->min)) {
×
41
            $restriction['minLength'] = (int) $constraint->min;
×
42
        }
43

44
        if (isset($constraint->max)) {
×
45
            $restriction['maxLength'] = (int) $constraint->max;
×
46
        }
47

48
        return $restriction;
×
49
    }
50

51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function supports(Constraint $constraint, ApiProperty $propertyMetadata): bool
55
    {
UNCOV
56
        if (method_exists(PropertyInfoExtractor::class, 'getType')) {
×
UNCOV
57
            $type = $propertyMetadata->getExtraProperties()['nested_schema'] ?? false ? Type::string() : $propertyMetadata->getNativeType();
×
58

UNCOV
59
            return $constraint instanceof Length && $type?->isIdentifiedBy(TypeIdentifier::STRING);
×
60
        }
61

62
        $types = array_map(fn (LegacyType $type) => $type->getBuiltinType(), $propertyMetadata->getBuiltinTypes() ?? []);
×
63
        if ($propertyMetadata->getExtraProperties()['nested_schema'] ?? false) {
×
64
            $types = [LegacyType::BUILTIN_TYPE_STRING];
×
65
        }
66

67
        return $constraint instanceof Length && \count($types) && \in_array(LegacyType::BUILTIN_TYPE_STRING, $types, true);
×
68
    }
69
}
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