2024-10-02 00:53:11 +02:00
|
|
|
<?php
|
|
|
|
|
2024-10-02 01:15:22 +02:00
|
|
|
namespace NoccyLabs\JsonEdit;
|
2024-10-02 00:53:11 +02:00
|
|
|
|
|
|
|
class Settings
|
|
|
|
{
|
|
|
|
public static bool $editorQuotedKeys = false;
|
|
|
|
|
|
|
|
public static function load(string $filename): void
|
|
|
|
{
|
|
|
|
if (file_exists($filename) && is_readable($filename)) {
|
|
|
|
$data = json_decode(file_get_contents($filename));
|
|
|
|
self::$editorQuotedKeys = $data->editorQuotedKeys ?? false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function save(string $filename): void
|
|
|
|
{
|
|
|
|
$data = json_encode([
|
|
|
|
'editorQuotedKeys' => self::$editorQuotedKeys
|
|
|
|
], JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT)."\n";
|
|
|
|
@file_put_contents($filename, $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function set(string $key, mixed $value): void
|
|
|
|
{
|
|
|
|
switch ($key) {
|
|
|
|
case 'editorQuotedKeys':
|
|
|
|
self::$editorQuotedKeys = (bool)$value; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|