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

api-platform / core / 9710726294

25 Jun 2024 02:01PM UTC coverage: 62.122% (-0.5%) from 62.637%
9710726294

push

github

web-flow
feat(laravel): laravel component (#5882)

* feat(laravel): laravel component

* try to skip laravel

* feat(jsonapi): component

* feat(laravel): json api support (needs review)

* work on relations

* relations (needs toMany) + skolem + IRI to resource

* links handler

* ulid

* validation

* slug post

* remove deprecations

* move classes

* fix tests

* fix tests metadata

* phpstan

* missing class

* fix laravel tests

* fix stan

33 of 77 new or added lines in 20 files covered. (42.86%)

140 existing lines in 15 files now uncovered.

10862 of 17485 relevant lines covered (62.12%)

59.64 hits per line

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

54.55
/src/JsonApi/Serializer/ReservedAttributeNameConverter.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\JsonApi\Serializer;
15

16
use Symfony\Component\Serializer\NameConverter\AdvancedNameConverterInterface;
17
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
18

19
/**
20
 * Reserved attribute name converter.
21
 *
22
 * @author Baptiste Meyer <baptiste.meyer@gmail.com>
23
 */
24
final class ReservedAttributeNameConverter implements AdvancedNameConverterInterface
25
{
26
    public const JSON_API_RESERVED_ATTRIBUTES = [
27
        'id' => '_id',
28
        'type' => '_type',
29
        'links' => '_links',
30
        'relationships' => '_relationships',
31
        'included' => '_included',
32
    ];
33

34
    public function __construct(private readonly ?NameConverterInterface $nameConverter = null)
35
    {
36
    }
352✔
37

38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function normalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string
42
    {
43
        if (null !== $this->nameConverter) {
52✔
44
            $propertyName = $this->nameConverter->normalize($propertyName, $class, $format, $context);
52✔
45
        }
46

47
        if (isset(self::JSON_API_RESERVED_ATTRIBUTES[$propertyName])) {
52✔
48
            $propertyName = self::JSON_API_RESERVED_ATTRIBUTES[$propertyName];
8✔
49
        }
50

51
        return $propertyName;
52✔
52
    }
53

54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string
58
    {
UNCOV
59
        if (\in_array($propertyName, self::JSON_API_RESERVED_ATTRIBUTES, true)) {
×
UNCOV
60
            $propertyName = substr($propertyName, 1);
×
61
        }
62

UNCOV
63
        if (null !== $this->nameConverter) {
×
UNCOV
64
            $propertyName = $this->nameConverter->denormalize($propertyName, $class, $format, $context);
×
65
        }
66

UNCOV
67
        return $propertyName;
×
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