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

api-platform / core / 9663895513

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

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

57.14
/src/Problem/Serializer/ErrorNormalizerTrait.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\Problem\Serializer;
15

16
use ApiPlatform\Metadata\Exception\ErrorCodeSerializableInterface;
17
use Symfony\Component\ErrorHandler\Exception\FlattenException;
18
use Symfony\Component\HttpFoundation\Response;
19

20
trait ErrorNormalizerTrait
21
{
22
    private function getErrorMessage($object, array $context, bool $debug = false): string
23
    {
24
        $message = $object->getMessage();
40✔
25

26
        if ($debug) {
40✔
27
            return $message;
20✔
28
        }
29

30
        if ($object instanceof FlattenException) {
20✔
31
            $statusCode = $context['statusCode'] ?? $object->getStatusCode();
16✔
32
            if ($statusCode >= 500 && $statusCode < 600) {
16✔
33
                $message = Response::$statusTexts[$statusCode] ?? Response::$statusTexts[Response::HTTP_INTERNAL_SERVER_ERROR];
12✔
34
            }
35
        }
36

37
        return $message;
20✔
38
    }
39

40
    private function getErrorCode(object $object): ?string
41
    {
UNCOV
42
        if ($object instanceof FlattenException) {
×
UNCOV
43
            $exceptionClass = $object->getClass();
×
44
        } else {
UNCOV
45
            $exceptionClass = $object::class;
×
46
        }
47

UNCOV
48
        if (is_a($exceptionClass, ErrorCodeSerializableInterface::class, true)) {
×
UNCOV
49
            return $exceptionClass::getErrorCode();
×
50
        }
51

UNCOV
52
        return null;
×
53
    }
54
}
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