Initial import from aternosorg/codex-minecraft
Some checks failed
Tests / Run tests on PHP v8.4 (push) Failing after 32s
Tests / Run tests on PHP v8.5 (push) Failing after 2s

This commit is contained in:
2026-04-30 09:56:57 -05:00
commit 7c7fe5ca80
94 changed files with 7003 additions and 0 deletions

50
src/Log/AnalysableLog.php Normal file
View File

@@ -0,0 +1,50 @@
<?php
namespace Aternos\Codex\Log;
use Aternos\Codex\Analyser\AnalyserInterface;
use Aternos\Codex\Analysis\AnalysisInterface;
/**
* Class AnalysableLog
*
* @package Aternos\Codex\Log
*/
abstract class AnalysableLog extends Log implements AnalysableLogInterface
{
protected ?AnalysisInterface $analysis = null;
/**
* Analyse a log file with an analyser
*
* Every log type should have a default analyser,
* but the $analyser argument can be used to override
* the default analyser
*
* @param AnalyserInterface|null $analyser
* @return AnalysisInterface
*/
public function analyse(?AnalyserInterface $analyser = null): AnalysisInterface
{
if ($this->analysis !== null) {
return $this->analysis;
}
if ($analyser === null) {
$analyser = static::getDefaultAnalyser();
}
$analyser->setLog($this);
return $this->analysis = $analyser->analyse();
}
/**
* @return array
*/
public function jsonSerialize(): array
{
return array_merge(parent::jsonSerialize(), [
'analysis' => $this->analyse()
]);
}
}