32 lines
854 B
PHP
32 lines
854 B
PHP
|
<?php
|
||
|
|
||
|
namespace NoccyLabs\JEdit;
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
}
|