Cacher gardening

This commit is contained in:
2021-06-17 22:03:32 +02:00
parent dd3085ca1d
commit 0fa7358c4b
4 changed files with 56 additions and 24 deletions
+23
View File
@@ -26,4 +26,27 @@ class utils
}
}
}
// does nothing if the directory already exists
public static function make_directory(string $directory) : void
{
if (!file_exists($directory))
{
mkdir($directory, 0777, true);
}
}
public static function load_json(string $path) : array
{
try
{
$raw = file_get_contents($path);
}
catch
{
$raw = "";
}
return json_decode($raw, true) ?? array();
}
}