<?php
/*
    Copyright (C) 2015 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
    MA 02110-1301  USA.
*/

namespace SiWeather\Webservice;

class WebserviceConfig {

	function __construct(){
		require(__DIR__ ."/../../config/config.php");
		$this->_config = $config;
		$this->loadAdditionalConfiguration();

		if($this->getConfig("mode") == "development"){
			error_reporting(E_ALL);
		}
	}
	
	private function loadAdditionalConfiguration(){
		$this->_config["dataDirectory"] = "data";
	}

	public function getConfig($key){
		if(!array_key_exists($key, $this->_config)){
			error_log("Expected config value ". $key ." does not exists");
			return FALSE;
		}
		
		if($key == "dataDirectory"){
// 			error_log("Use dataDirectory() function to access this value");
			return $this->dataDirectory();
		}
		
		return $this->_config[$key];
	}

	public function dataDirectory(){
		return __DIR__ ."/../../". $this->_config["dataDirectory"];
	}

	private $_config;
}

?>
