. * * @author TechFuze * @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net) * @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/) * @license http://opensource.org/licenses/GPL-3.0 GPLv3 License * * @link http://fuzeworks.techfuze.net * @since Version 0.0.1 * * @version Version 0.0.1 */ namespace FuzeWorks\ConfigORM; use ConfigException; /** * ORM class for config files in PHP files. * * Handles entries in the config directory of FuzeWorks and is able to dynamically update them when requested * * @author Abel Hoogeveen * @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net) * @todo Implement unit tests */ class ConfigORM extends ConfigORMAbstract { /** * The current filename. * * @var string filename */ private $file; /** * Sets up the class and the connection to the PHP file. * * @param string $filename The current filename * * @throws ConfigException on fatal error */ public function __construct($file = null) { if (is_null($file)) { throw new ConfigException('Could not load config file. No file provided', 1); } elseif (file_exists($file)) { $this->file = $file; $this->cfg = (array) include $file; $this->originalCfg = $this->cfg; } else { throw new ConfigException('Could not load config file. Config file does not exist', 1); } } /** * Updates the config file and writes it. * * @throws ConfigException on fatal error */ public function commit() { // Write the changes if (is_writable($this->file)) { $config = var_export($this->cfg, true); file_put_contents($this->file, "