Add messagebox, bugfixes
This commit is contained in:
32
src/Settings.php
Normal file
32
src/Settings.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user