1
0
mirror of https://github.com/flarum/core.git synced 2025-07-25 10:41:24 +02:00
Files
php-flarum/src/Frontend/Compiler/Source/FileSource.php
Franz Liedke d492579638 Apply fixes from StyleCI
[ci skip] [skip ci]
2019-11-28 00:16:50 +00:00

57 lines
1020 B
PHP

<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Frontend\Compiler\Source;
use InvalidArgumentException;
class FileSource implements SourceInterface
{
/**
* @var string
*/
protected $path;
/**
* @param string $path
*/
public function __construct(string $path)
{
if (! file_exists($path)) {
throw new InvalidArgumentException("File not found at path: $path");
}
$this->path = $path;
}
/**
* @return string
*/
public function getContent(): string
{
return file_get_contents($this->path);
}
/**
* @return mixed
*/
public function getCacheDifferentiator()
{
return [$this->path, filemtime($this->path)];
}
/**
* @return string
*/
public function getPath(): string
{
return $this->path;
}
}