coniadev /
error
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Conia\Error; |
||
| 6 | |||
| 7 | use Throwable; |
||
| 8 | |||
| 9 | class RendererEntry |
||
| 10 | { |
||
| 11 | private string|int|null $logLevel = null; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @param class-string<Throwable>[] $exceptions |
||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
| 15 | */ |
||
| 16 | 10 | public function __construct( |
|
| 17 | public readonly array $exceptions, |
||
| 18 | public readonly Renderer $renderer |
||
| 19 | ) { |
||
| 20 | 10 | } |
|
| 21 | |||
| 22 | 9 | public function matches(Throwable $exception): bool |
|
| 23 | { |
||
| 24 | 9 | foreach ($this->exceptions as $exceptionEntry) { |
|
| 25 | 9 | if ($exception::class === $exceptionEntry) { |
|
| 26 | 5 | return true; |
|
| 27 | } |
||
| 28 | |||
| 29 | 4 | if (is_subclass_of($exception::class, $exceptionEntry)) { |
|
| 30 | 3 | return true; |
|
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 | 1 | return false; |
|
| 35 | } |
||
| 36 | |||
| 37 | /** @psalm-api */ |
||
| 38 | 1 | public function log(string|int $logLevel): void |
|
| 39 | { |
||
| 40 | 1 | $this->logLevel = $logLevel; |
|
| 41 | } |
||
| 42 | |||
| 43 | 8 | public function getLogLevel(): string|int|null |
|
| 44 | { |
||
| 45 | 8 | return $this->logLevel; |
|
| 46 | } |
||
| 47 | } |
||
| 48 |