HttpExceptionFormatter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

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