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

ThrowableFormatter::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
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 Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
11
use Symfony\Component\HttpFoundation\Response;
12
13
#[AutoconfigureTag(ExceptionFormatterLocator::EXCEPTION_FORMATTERS_TAG)]
14 1
class ThrowableFormatter implements FormatterInterface
15
{
16 1
    public function __invoke(\Throwable $e): ContractErrorInterface
17
    {
18 1
        return new ContractError('Internal Server Error', Response::HTTP_INTERNAL_SERVER_ERROR, trace: $e->getTrace());
19
    }
20
21 1
    public static function getExceptionClass(): string
22
    {
23 1
        return \Throwable::class;
24
    }
25
26 1
    public static function getPriority(): int
27
    {
28 1
        return 0;
29
    }
30
}
31