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

ThrowableFormatter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 16
ccs 7
cts 7
cp 1
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getPriority() 0 3 1
A getExceptionClass() 0 3 1
A __invoke() 0 3 1
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