/** * * @param array|Object $config */ public function __construct(array $config = null) { $this->_fingerprintOrder = new WirecardCEE_Stdlib_FingerprintOrder(); //if no config was sent fallback to default config file if (is_null($config)) { $config = WirecardCEE_QMore_Module::getConfig(); } if (isset($config['WirecardCEEQMoreConfig'])) { //we only need the WirecardCEEQMoreConfig here $config = $config['WirecardCEEQMoreConfig']; } //let's store configuration details in internal objects $this->oUserConfig = is_object($config) ? $config : new WirecardCEE_Stdlib_Config($config); $this->oClientConfig = new WirecardCEE_Stdlib_Config(WirecardCEE_QMore_Module::getClientConfig()); self::$FRAMEWORK_NAME = $this->getClientConfig()->DEPENDENCIES->FRAMEWORK_NAME; //now let's check if the CUSTOMER_ID, SHOP_ID, LANGUAGE and SECRET exist in $this->oUserConfig object that we've created from config array $sCustomerId = isset($this->oUserConfig->CUSTOMER_ID) ? trim($this->oUserConfig->CUSTOMER_ID) : null; $sShopId = isset($this->oUserConfig->SHOP_ID) ? trim($this->oUserConfig->SHOP_ID) : null; $sLanguage = isset($this->oUserConfig->LANGUAGE) ? trim($this->oUserConfig->LANGUAGE) : null; $sSecret = isset($this->oUserConfig->SECRET) ? trim($this->oUserConfig->SECRET) : null; //If not throw the InvalidArgumentException exception! if (empty($sCustomerId) || is_null($sCustomerId)) { throw new WirecardCEE_QMore_Exception_InvalidArgumentException(sprintf('CUSTOMER_ID passed to %s is invalid.', __METHOD__)); } if (empty($sLanguage) || is_null($sLanguage)) { throw new WirecardCEE_QMore_Exception_InvalidArgumentException(sprintf('LANGUAGE passed to %s is invalid.', __METHOD__)); } if (empty($sSecret) || is_null($sSecret)) { throw new WirecardCEE_QMore_Exception_InvalidArgumentException(sprintf('SECRET passed to %s is invalid.', __METHOD__)); } //everything ok! let's set the fields $this->_setField(self::SHOP_ID, $sShopId); $this->_setField(self::CUSTOMER_ID, $sCustomerId); $this->_setField(self::LANGUAGE, $sLanguage); $this->_setSecret($sSecret); }