Initial import from aternosorg/codex-minecraft
This commit is contained in:
13
test/src/Analysis/TestInformation.php
Normal file
13
test/src/Analysis/TestInformation.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Aternos\Codex\Test\Src\Analysis;
|
||||
|
||||
use Aternos\Codex\Analysis\Information;
|
||||
|
||||
/**
|
||||
* Class TestInformation
|
||||
*/
|
||||
class TestInformation extends Information
|
||||
{
|
||||
protected ?string $label = "Label";
|
||||
}
|
||||
33
test/src/Analysis/TestInsight.php
Normal file
33
test/src/Analysis/TestInsight.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Aternos\Codex\Test\Src\Analysis;
|
||||
|
||||
use Aternos\Codex\Analysis\Insight;
|
||||
use Aternos\Codex\Analysis\InsightInterface;
|
||||
|
||||
/**
|
||||
* Class TestInsight
|
||||
*/
|
||||
class TestInsight extends Insight
|
||||
{
|
||||
/**
|
||||
* Get the insight as human-readable message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMessage(): string
|
||||
{
|
||||
return "This is a test insight";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the $insight object is equal with the current object
|
||||
*
|
||||
* @param InsightInterface $insight
|
||||
* @return bool
|
||||
*/
|
||||
public function isEqual(InsightInterface $insight): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
43
test/src/Analysis/TestPatternInformation.php
Normal file
43
test/src/Analysis/TestPatternInformation.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Aternos\Codex\Test\Src\Analysis;
|
||||
|
||||
use Aternos\Codex\Analysis\Information;
|
||||
use Aternos\Codex\Analysis\PatternInsightInterface;
|
||||
|
||||
/**
|
||||
* Class TestPatternInformation
|
||||
*/
|
||||
class TestPatternInformation extends Information implements PatternInsightInterface
|
||||
{
|
||||
protected ?string $label = "Software version";
|
||||
|
||||
/**
|
||||
* Get an array of possible patterns
|
||||
*
|
||||
* The array key of the pattern will be passed to setMatches()
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getPatterns(): array
|
||||
{
|
||||
return ['/This log was generated by software (v[0-9\.]*)/'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the matches from the pattern
|
||||
*
|
||||
* @param array $matches
|
||||
* @param mixed $patternKey
|
||||
* @return void
|
||||
*/
|
||||
public function setMatches(array $matches, mixed $patternKey): void
|
||||
{
|
||||
$this->value = $matches[1];
|
||||
}
|
||||
|
||||
public function getLogContent(): ?string
|
||||
{
|
||||
return parent::getLogContent();
|
||||
}
|
||||
}
|
||||
70
test/src/Analysis/TestPatternProblem.php
Normal file
70
test/src/Analysis/TestPatternProblem.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace Aternos\Codex\Test\Src\Analysis;
|
||||
|
||||
use Aternos\Codex\Analysis\InsightInterface;
|
||||
use Aternos\Codex\Analysis\PatternInsightInterface;
|
||||
use Aternos\Codex\Analysis\Problem;
|
||||
|
||||
/**
|
||||
* Class TestPatternProblem
|
||||
*/
|
||||
class TestPatternProblem extends Problem implements PatternInsightInterface
|
||||
{
|
||||
protected ?string $cause = null;
|
||||
|
||||
/**
|
||||
* @param string $cause
|
||||
* @return TestPatternProblem
|
||||
*/
|
||||
public function setCause(string $cause): static
|
||||
{
|
||||
$this->cause = $cause;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of possible patterns
|
||||
*
|
||||
* The array key of the pattern will be passed to setMatches()
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getPatterns(): array
|
||||
{
|
||||
return ['/I have a problem with (\w+)/'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the matches from the pattern
|
||||
*
|
||||
* @param array $matches
|
||||
* @param mixed $patternKey
|
||||
* @return void
|
||||
*/
|
||||
public function setMatches(array $matches, mixed $patternKey): void
|
||||
{
|
||||
$this->cause = $matches[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the problem as human-readable message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMessage(): string
|
||||
{
|
||||
return "There is a problem with " . $this->cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the $insight object is equal with the current object
|
||||
*
|
||||
* @param InsightInterface $insight
|
||||
* @return bool
|
||||
*/
|
||||
public function isEqual(InsightInterface $insight): bool
|
||||
{
|
||||
return $insight instanceof static && $this->cause === $insight->cause;
|
||||
}
|
||||
}
|
||||
33
test/src/Analysis/TestProblem.php
Normal file
33
test/src/Analysis/TestProblem.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Aternos\Codex\Test\Src\Analysis;
|
||||
|
||||
use Aternos\Codex\Analysis\InsightInterface;
|
||||
use Aternos\Codex\Analysis\Problem;
|
||||
|
||||
/**
|
||||
* Class TestProblem
|
||||
*/
|
||||
class TestProblem extends Problem
|
||||
{
|
||||
/**
|
||||
* Get the problem as human-readable message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMessage(): string
|
||||
{
|
||||
return "This is a test problem";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the $insight object is equal with the current object
|
||||
*
|
||||
* @param InsightInterface $insight
|
||||
* @return bool
|
||||
*/
|
||||
public function isEqual(InsightInterface $insight): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
21
test/src/Analysis/TestSolution.php
Normal file
21
test/src/Analysis/TestSolution.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Aternos\Codex\Test\Src\Analysis;
|
||||
|
||||
use Aternos\Codex\Analysis\Solution;
|
||||
|
||||
/**
|
||||
* Class TestSolution
|
||||
*/
|
||||
class TestSolution extends Solution
|
||||
{
|
||||
/**
|
||||
* Get the solution as a human-readable message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMessage(): string
|
||||
{
|
||||
return "This is a test solution.";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user