diff options
author | nornholdj <nornholdj@gmail.com> | 2014-10-22 17:18:53 -0400 |
---|---|---|
committer | nornholdj <nornholdj@gmail.com> | 2014-10-22 17:18:53 -0400 |
commit | c004fdc8fd6140d0074000ae112e7d0ca70437c1 (patch) | |
tree | ec3eb92e2d1c7081559a3d05f4ad184630482121 /lib/MessageSystems | |
parent | d9d40f3ce24068d5a0d0fecb4aa9cffcf15c5555 (diff) | |
download | php-sparkpost-c004fdc8fd6140d0074000ae112e7d0ca70437c1.zip php-sparkpost-c004fdc8fd6140d0074000ae112e7d0ca70437c1.tar.gz php-sparkpost-c004fdc8fd6140d0074000ae112e7d0ca70437c1.tar.bz2 |
MA-946 #time 2h Wrote Configuration Unit tests.
Diffstat (limited to 'lib/MessageSystems')
-rw-r--r-- | lib/MessageSystems/Configuration.php | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/MessageSystems/Configuration.php b/lib/MessageSystems/Configuration.php index 9f7c4ea..106d1d5 100644 --- a/lib/MessageSystems/Configuration.php +++ b/lib/MessageSystems/Configuration.php @@ -13,10 +13,16 @@ class Configuration { 'version'=>'v1' ]; + /** + * Enforce that this object can't be instansiated + */ + private function __construct(){} - private function __constructor(){ - } - + /** + * Allows the user to pass in values to override the defaults and set their API key + * @param Array $configMap - Hashmap that contains config values for the SDK to connect to SparkPost + * @throws \Exception + */ public static function setConfig($configMap) { //check for API key because its required if (!isset($configMap['key']) || empty(trim($configMap['key']))){ @@ -24,10 +30,16 @@ class Configuration { } self::$config = self::$defaults; foreach ($configMap as $configOption => $configValue) { - self::$config[$configOption] = $configValue; + if(key_exists($configOption, self::$config)) { + self::$config[$configOption] = $configValue; + } } } + /** + * Retrieves the configuration that was previously setup by the user + * @throws \Exception + */ public static function getConfig() { if (self::$config === null) { throw new \Exception('No configuration has been provided'); |