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

api-platform / core / 17327553156

29 Aug 2025 03:13PM UTC coverage: 22.588% (-0.03%) from 22.622%
17327553156

push

github

web-flow
fix(laravel): serialization issue with camelCase relation (#7356)

fixes #7344

0 of 76 new or added lines in 9 files covered. (0.0%)

11415 existing lines in 372 files now uncovered.

11181 of 49499 relevant lines covered (22.59%)

23.68 hits per line

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

80.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)) {
32✔
28
            return $v;
×
29
        }
30

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

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

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

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

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

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

UNCOV
57
        return false === $value ? $v : $value;
20✔
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

© 2026 Coveralls, Inc