HttpExceptionFormatter::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 1
cts 1
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FRZB\Component\RequestMapper\ExceptionFormatter\Formatter;
6
7
use FRZB\Component\DependencyInjection\Attribute\AsService;
8
use FRZB\Component\DependencyInjection\Attribute\AsTagged;
9
use FRZB\Component\RequestMapper\Data\ErrorContract;
10
use FRZB\Component\RequestMapper\Data\FormattedError;
11
use JetBrains\PhpStorm\Pure;
12
use Symfony\Component\HttpKernel\Exception\HttpException;
13
14
#[AsService, AsTagged(FormatterInterface::class)]
15
class HttpExceptionFormatter implements FormatterInterface
16 1
{
17
    #[Pure]
18
    public function __invoke(HttpException $e): ErrorContract
19 1
    {
20
        return new FormattedError($e->getMessage(), $e->getStatusCode(), trace: $e->getTrace());
21
    }
22 1
23
    public static function getExceptionClass(): string
24 1
    {
25
        return HttpException::class;
26
    }
27 1
28
    public static function getPriority(): int
29 1
    {
30
        return 2;
31
    }
32
}
33