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

api-platform / core / 18060089452

27 Sep 2025 12:57PM UTC coverage: 0.0% (-21.8%) from 21.793%
18060089452

Pull #7397

github

web-flow
Merge 479f46b8d into abe0438be
Pull Request #7397: fix(jsonschema/jsonld): make `@id` and `@type` properties required only in the JSON-LD schema for output

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

11967 existing lines in 393 files now uncovered.

0 of 53914 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/State/Parameter/ValueCaster.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\State\Parameter;
15

16
/**
17
 * Caster returns the default value when a value can not be casted
18
 * This is used by parameters before they get validated by constraints
19
 * Therefore we do not need to throw exceptions, validation will just fail.
20
 *
21
 * @internal
22
 */
23
final class ValueCaster
24
{
25
    public static function toBool(mixed $v): mixed
26
    {
UNCOV
27
        if (!\is_string($v)) {
×
28
            return $v;
×
29
        }
30

UNCOV
31
        return match (strtolower($v)) {
×
UNCOV
32
            '1', 'true' => true,
×
UNCOV
33
            '0', 'false' => false,
×
UNCOV
34
            default => $v,
×
UNCOV
35
        };
×
36
    }
37

38
    public static function toInt(mixed $v): mixed
39
    {
UNCOV
40
        if (\is_int($v)) {
×
41
            return $v;
×
42
        }
43

UNCOV
44
        $value = filter_var($v, \FILTER_VALIDATE_INT);
×
45

UNCOV
46
        return false === $value ? $v : $value;
×
47
    }
48

49
    public static function toFloat(mixed $v): mixed
50
    {
UNCOV
51
        if (\is_float($v)) {
×
52
            return $v;
×
53
        }
54

UNCOV
55
        $value = filter_var($v, \FILTER_VALIDATE_FLOAT);
×
56

UNCOV
57
        return false === $value ? $v : $value;
×
58
    }
59
}
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