Untitled
unknown
php
7 months ago
538 B
9
Indexable
<?php
final class ExceptionHandlerResolver
{
/** @var List<ExceptionHandler> */
private array $handlers = [];
public function __construct(
private readonly Arr $arr
) {}
public function addHandler(ExceptionHandler $handler): void
{
$this->handlers[] = $handler;
}
private function getHandler(Throwable $exception): ?ExceptionHandler
{
return $this->arr::first(
$this->handlers,
static fn ($handler) => $handler->handles($exception)
);
}
}
Editor is loading...
Leave a Comment