for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Spiral\LogViewer\Entities;
use Symfony\Component\Finder\SplFileInfo;
class LogFile
{
/** @var SplFileInfo */
private $file;
/**
* Log constructor.
*
* @param $file
*/
public function __construct($file)
if ($file instanceof SplFileInfo) {
$this->file = $file;
} elseif (is_string($file)) {
$this->file = new SplFileInfo($file, dirname($file), basename($file));
} else {
throw new \InvalidArgumentException(sprintf(
'Unsupported file, string or "%s" instance is waiting.',
SplFileInfo::class
));
}
* @return string
public function filename(): string
return $this->file->getRealPath();
public function name(): string
return $this->file->getFilename();
* @return int
public function size(): int
return $this->file->getSize();
* @return LogTimestamp
public function timestamp(): LogTimestamp
return new LogTimestamp($this->file->getMTime(), []);
public function content(): string
return $this->file->getContents();