Passed
Push — main ( 02aafc...c60ca1 )
by Fractal
02:41
created

HttpExceptionFormatter::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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