/** * 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; }
/** * Default Constructor * * @param HttpConfig $httpConfig * @param array $config * @throws BitPagosConfigurationException */ public function __construct(HttpConfig $httpConfig, array $config) { if (!function_exists("curl_init")) { throw new BitPagosConfigurationException("Curl module is not available on this system"); } $this->httpConfig = $httpConfig; $this->logger = LoggingManager::getInstance(__CLASS__); }
/** * Default Constructor * * @param ApiContext $apiContext */ public function __construct(ApiContext $apiContext) { $this->apiContext = $apiContext; $this->logger = LoggingManager::getInstance(__CLASS__); }