Test Failed
Pull Request — main (#22)
by Fractal
13:00
created

HttpExceptionFormatter::getExceptionClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
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\ValueObject\ErrorContract;
10
use FRZB\Component\RequestMapper\ValueObject\FormattedError;
11
use JetBrains\PhpStorm\Pure;
12
use Symfony\Component\HttpKernel\Exception\HttpException;
13
14
#[AsService, AsTagged(FormatterInterface::class, priority: 1)]
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 getType(): string
24 1
    {
25
        return HttpException::class;
26
    }
27
}
28