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

api-platform / core / 10963383095

20 Sep 2024 05:06PM UTC coverage: 7.834%. Remained the same
10963383095

push

github

soyuka
test(laravel): standard put model should update when it exists

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

342 existing lines in 15 files now uncovered.

12915 of 164861 relevant lines covered (7.83%)

27.03 hits per line

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

100.0
/src/Hydra/Serializer/HydraPrefixNameConverter.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\Hydra\Serializer;
15

16
use ApiPlatform\JsonLd\ContextBuilder;
17
use Symfony\Component\Serializer\NameConverter\AdvancedNameConverterInterface;
18
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
19

20
final readonly class HydraPrefixNameConverter implements NameConverterInterface, AdvancedNameConverterInterface
21
{
22
    /**
23
     * @param array<string,mixed> $defaultContext
24
     */
25
    public function __construct(private NameConverterInterface $nameConverter, private array $defaultContext = [])
26
    {
27
    }
2,670✔
28

29
    public function normalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string
30
    {
31
        $context += $this->defaultContext;
2,488✔
32
        $name = $this->nameConverter->normalize($propertyName, $class, $format, $context);
2,488✔
33

34
        if (true === ($context[ContextBuilder::HYDRA_CONTEXT_HAS_PREFIX] ?? true)) {
2,488✔
35
            return $name;
2,484✔
36
        }
37

UNCOV
38
        return str_starts_with($name, ContextBuilder::HYDRA_PREFIX) ? str_replace(ContextBuilder::HYDRA_PREFIX, '', $name) : $name;
43✔
39
    }
40

41
    public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string
42
    {
43
        return $this->nameConverter->denormalize($propertyName, $class, $format, $context);
1,301✔
44
    }
45
}
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