Files
logview/app/common/Service/Logs.php
2023-02-14 17:27:01 -03:00

45 lines
977 B
PHP

<?php
namespace ProVM\Common\Service;
use ProVM\Logview\Log\File;
class Logs
{
public function __construct(string $folder)
{
$this
->setFolder($folder);
}
protected string $folder;
public function getFolder(): string
{
return $this->folder;
}
public function setFolder(string $folder): Logs
{
$this->folder = $folder;
return $this;
}
public function getFiles(): array
{
$files = new \FilesystemIterator($this->getFolder());
$output = [];
foreach ($files as $file) {
if ($file->isDir()) {
continue;
}
$output []= $file;
}
return $output;
}
public function get(string $log_file): File
{
$content = \Safe\file_get_contents(implode(DIRECTORY_SEPARATOR, [$this->getFolder(), $log_file]));
return (new File())->setFilename($log_file)->setContent($content);
}
}