Add ServerExceptionProblem insight
This commit is contained in:
46
src/Analysis/ProjectZomboid/ServerExceptionProblem.php
Normal file
46
src/Analysis/ProjectZomboid/ServerExceptionProblem.php
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user