Add ServerExceptionProblem insight

This commit is contained in:
2026-04-30 21:33:07 +00:00
parent 1d09358e7b
commit 423c6d3963
3 changed files with 110 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
<?php
namespace IndifferentKetchup\Codex\Analysis\ProjectZomboid;
use IndifferentKetchup\Codex\Analysis\InsightInterface;
use IndifferentKetchup\Codex\Analysis\PatternInsightInterface;
use IndifferentKetchup\Codex\Analysis\Problem;
use IndifferentKetchup\Codex\Pattern\ProjectZomboid\DebugServerPattern;
class ServerExceptionProblem extends Problem implements PatternInsightInterface
{
private string $exceptionType = '';
private string $body = '';
public static function getPatterns(): array
{
return [DebugServerPattern::EXCEPTION];
}
public function setMatches(array $matches, mixed $patternKey): void
{
$this->exceptionType = $matches['type'];
$this->body = trim($matches['body'] ?? '');
}
public function getExceptionType(): string
{
return $this->exceptionType;
}
public function getBody(): string
{
return $this->body;
}
public function getMessage(): string
{
return sprintf('Exception thrown: %s', $this->exceptionType);
}
public function isEqual(InsightInterface $insight): bool
{
return $insight instanceof self
&& $insight->getExceptionType() === $this->exceptionType;
}
}