$value) { self::set($name, $value); } } /** * Read configuration overrides as JSON string form PHP or JSON file * and decode the returned string. Note that now the configuration is stored in * PHP files instead of JSON files to make it less easy to access from outside. * * @return array The configuration array */ public static function read(): array { $json = false; $config = array(); if (is_readable(self::$file)) { $json = require self::$file; } elseif (is_readable(self::$legacy)) { // Support legacy configuration files. $json = file_get_contents(self::$legacy); } if ($json) { $config = json_decode($json, true); } return $config; } /** * Define constant, if not defined already. * * @param string $name * @param mixed $value */ public static function set(string $name, mixed $value): void { if (!defined($name)) { define($name, $value); } } /** * Write the configuration file. * * @param array $config * @return bool True on success */ public static function write(array $config): bool { $json = json_encode($config, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES); $content = "