App src code
This commit is contained in:
44
app/src/Log/File.php
Normal file
44
app/src/Log/File.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
namespace ProVM\Logview\Log;
|
||||
|
||||
use Generator;
|
||||
use ProVM\Logview\Log;
|
||||
|
||||
class File
|
||||
{
|
||||
protected string $filename;
|
||||
protected string $content;
|
||||
|
||||
public function getFilename(): string
|
||||
{
|
||||
return $this->filename;
|
||||
}
|
||||
public function getContent(): string
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function setFilename(string $filename): File
|
||||
{
|
||||
$this->filename = $filename;
|
||||
return $this;
|
||||
}
|
||||
public function setContent(string $content): File
|
||||
{
|
||||
$this->content = $content;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLogs(): array
|
||||
{
|
||||
$lines = explode(PHP_EOL, $this->getContent());
|
||||
$logs = [];
|
||||
foreach ($lines as $line) {
|
||||
if (trim($line) === '') {
|
||||
continue;
|
||||
}
|
||||
$logs []= Log::parse($line);
|
||||
}
|
||||
return array_reverse($logs);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user