ExceptionMapperLocatorException::notFound()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 7
rs 10
c 0
b 0
f 0
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