-
-
Notifications
You must be signed in to change notification settings - Fork 167
Expand file tree
/
Copy pathFilesystem.php
More file actions
42 lines (32 loc) · 925 Bytes
/
Filesystem.php
File metadata and controls
42 lines (32 loc) · 925 Bytes
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
<?php
declare(strict_types=1);
namespace Safe\Templating;
final class Filesystem
{
private function __construct()
{
}
public static function projectRootDir(): string
{
$path = realpath(__DIR__ . '/../../..');
if (false === $path) {
throw new \RuntimeException('Unable to locate root directory');
}
return $path;
}
public static function generatorDir(): string
{
return \sprintf(self::projectRootDir().'/generator');
}
public static function outputDir(): string
{
return \sprintf(self::projectRootDir().'/generated');
}
public static function dumpFile(string $targetPath, string $content): void
{
$result = file_put_contents($targetPath, $content);
if (false === $result) {
throw new \RuntimeException(\sprintf('Could not write to "%s".', $targetPath));
}
}
}