-
-
Notifications
You must be signed in to change notification settings - Fork 829
/
FileSource.php
52 lines (43 loc) · 1.03 KB
/
FileSource.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?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;
/**
* @internal
*/
class FileSource implements SourceInterface
{
public function __construct(
protected string $path,
protected ?string $extensionId = null
) {
if (! file_exists($path)) {
throw new InvalidArgumentException("File not found at path: $path");
}
}
public function getContent(): string
{
return file_get_contents($this->path);
}
public function getCacheDifferentiator(): array
{
return [$this->path, filemtime($this->path)];
}
public function getPath(): string
{
return $this->path;
}
public function setPath(string $path): void
{
$this->path = $path;
}
public function getExtensionId(): ?string
{
return $this->extensionId;
}
}