ExceptionMapperLocatorException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 12
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A notFound() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FRZB\Component\RequestMapper\Exception;
6
7
use JetBrains\PhpStorm\Immutable;
8
use JetBrains\PhpStorm\Pure;
9
10
#[Immutable]
11
final class ExceptionMapperLocatorException extends \DomainException
12
{
13
    private const NOT_FOUND_MESSAGE = 'No mapper found for exception "%s"';
14
15
    #[Pure(true)]
16
    public static function notFound(\Throwable $previous, bool $wrapCallable = true): callable|self
17
    {
18
        $message = sprintf(self::NOT_FOUND_MESSAGE, $previous::class);
19
        $exception = new self($message, previous: $previous);
20
21
        return $wrapCallable ? static fn () => throw $exception : $exception;
22
    }
23
}
24