/** * Create singleton instance for this class. * * @param array|null $config * @return CredentialManager */ public static function getInstance($config = null) { if (!self::$instance) { self::$instance = new self($config == null ? ConfigManager::getInstance()->getConfigHashmap() : $config); } return self::$instance; }
/** * Helper method for validating if the class contains accessor methods (getter and setter) for a given attribute * * @param BitPagosModel $class * An object of BitPagosModel * @param string $attributeName * Attribute name * @return bool */ public static function validate(BitPagosModel $class, $attributeName) { $mode = ConfigManager::getInstance()->get('validation.level'); if (!empty($mode) && $mode != 'disabled') { //Check if $attributeName is string if (gettype($attributeName) !== 'string') { return false; } //If the mode is disabled, bypass the validation foreach (array('set' . $attributeName, 'get' . $attributeName) as $methodName) { if (get_class($class) == get_class(new BitPagosModel())) { // Silently return false on cases where you are using BitPagosModel instance directly return false; } elseif (!method_exists($class, $methodName)) { //Delegate the error based on the choice $className = is_object($class) ? get_class($class) : (string) $class; $errorMessage = "Missing Accessor: {$className}:{$methodName}. You might be using older version of SDK. If not, create an issue at https://github.com/welcome2ba/bitpagos-api-sdk-php/issues"; LoggingManager::getInstance(__CLASS__)->debug($errorMessage); if ($mode == 'strict') { trigger_error($errorMessage, E_USER_NOTICE); } return false; } } return true; } return false; }
/** * Gets a specific configuration from key * * @param * $searchKey * @return mixed */ public function get($searchKey) { return ConfigManager::getInstance()->get($searchKey); }