diff options
Diffstat (limited to 'lib/MessageSystems/Configuration.php')
-rw-r--r-- | lib/MessageSystems/Configuration.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/MessageSystems/Configuration.php b/lib/MessageSystems/Configuration.php new file mode 100644 index 0000000..9f7c4ea --- /dev/null +++ b/lib/MessageSystems/Configuration.php @@ -0,0 +1,39 @@ +<?php +namespace MessageSystems; + +class Configuration { + + private static $config; + private static $defaults = [ + 'host'=>'app.cloudplaceholder.com', + 'protocol'=>'https', + 'port'=>443, + 'strictSSL'=>true, + 'key'=>'', + 'version'=>'v1' + ]; + + + private function __constructor(){ + } + + public static function setConfig($configMap) { + //check for API key because its required + if (!isset($configMap['key']) || empty(trim($configMap['key']))){ + throw new \Exception('You must provide an API key'); + } + self::$config = self::$defaults; + foreach ($configMap as $configOption => $configValue) { + self::$config[$configOption] = $configValue; + } + } + + public static function getConfig() { + if (self::$config === null) { + throw new \Exception('No configuration has been provided'); + } + return self::$config; + } +} + +?>
\ No newline at end of file |