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

api-platform / core / 7142557150

08 Dec 2023 02:28PM UTC coverage: 36.003% (-1.4%) from 37.36%
7142557150

push

github

web-flow
fix(jsonld): remove link to ApiDocumentation when doc is disabled (#6029)

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

2297 existing lines in 182 files now uncovered.

9992 of 27753 relevant lines covered (36.0%)

147.09 hits per line

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

50.0
/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\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();
84✔
25

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

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

UNCOV
37
        return $message;
×
38
    }
39

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

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

52
        return null;
6✔
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

© 2026 Coveralls, Inc