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

23
src/Log/File/LogFile.php Normal file
View File

@@ -0,0 +1,23 @@
<?php
namespace Aternos\Codex\Log\File;
/**
* Class LogFile
*
* @package Aternos\Codex\Log\File
*/
abstract class LogFile implements LogFileInterface
{
protected ?string $content = null;
/**
* Get the log file content
*
* @return string
*/
public function getContent(): string
{
return $this->content;
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace Aternos\Codex\Log\File;
/**
* Interface LogFileInterface
*
* @package Aternos\Codex\Log\File
*/
interface LogFileInterface
{
/**
* Get the log file content
*
* @return string
*/
public function getContent(): string;
}

View File

@@ -0,0 +1,27 @@
<?php
namespace Aternos\Codex\Log\File;
use InvalidArgumentException;
/**
* Class PathLogFile
*
* @package Aternos\Codex\Log\File
*/
class PathLogFile extends LogFile
{
/**
* PathLogFile constructor.
*
* @param string $path
*/
public function __construct(string $path)
{
if (!file_exists($path)) {
throw new InvalidArgumentException("File '" . $path . "' not found.");
}
$this->content = file_get_contents($path);
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Aternos\Codex\Log\File;
use InvalidArgumentException;
/**
* Class StreamLogFile
*
* @package Aternos\Codex\Log\File
*/
class StreamLogFile extends LogFile
{
/**
* StreamLogFile constructor.
*
* @param resource $streamResource
*/
public function __construct($streamResource)
{
if (!is_resource($streamResource)) {
throw new InvalidArgumentException("Stream argument is not a resource");
}
$this->content = '';
while (!feof($streamResource)) {
$this->content .= fread($streamResource, 8192);
}
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Aternos\Codex\Log\File;
/**
* Class StringLogFile
*
* @package Aternos\Codex\Log\File
*/
class StringLogFile extends LogFile
{
/**
* StringLogFile constructor.
*
* @param string $string
*/
public function __construct(string $string)
{
$this->content = $string;
}
}