/**
  * @param $params
  * @param $allowedParams
  * @param string $validationLevel allows override global validation level settings
  * @return array
  */
 public static function sanitize($params, $allowedParams, $validationLevel = null)
 {
     $notAllowedParams = self::getNotAllowedParams($params, $allowedParams);
     if (count($notAllowedParams) > 0) {
         if ($validationLevel === null) {
             $validationLevel = BlockCypherConfigManager::getInstance()->get('validation.level');
         }
         foreach ($notAllowedParams as $key => $value) {
             $validationMessage = "Param {$key} not allowed: It can be a typo in the param name or you should update the PHP SDK library.";
             switch ($validationLevel) {
                 case 'log':
                     // logs the error message to logger only (default)
                     $logger = BlockCypherLoggingManager::getInstance(__CLASS__);
                     $logger->warning($validationMessage);
                     break;
                 case 'strict':
                     // throws a php notice message
                     trigger_error($validationMessage, E_USER_NOTICE);
                     break;
                 case 'disable':
                     // disable the validation
                     break;
             }
         }
         if ($validationLevel == 'strict') {
             // Do not add not allowed params to the url
             $params = array_intersect_key($params, $allowedParams);
             return $params;
         }
         return $params;
     }
     return $params;
 }
 /**
  * Default Constructor
  *
  * @param BlockCypherHttpConfig $httpConfig
  * @param array $config
  * @throws BlockCypherConfigurationException
  */
 public function __construct(BlockCypherHttpConfig $httpConfig, array $config)
 {
     if (!function_exists("curl_init")) {
         throw new BlockCypherConfigurationException("Curl module is not available on this system");
     }
     $this->httpConfig = $httpConfig;
     $this->logger = BlockCypherLoggingManager::getInstance(__CLASS__);
 }
 /**
  * Helper method for validating if the class contains accessor methods (getter and setter) for a given attribute
  *
  * @param BlockCypherModel $class An object of BlockCypherModel
  * @param string $attributeName Attribute name
  * @return bool
  */
 public static function validate(BlockCypherModel $class, $attributeName)
 {
     $mode = BlockCypherConfigManager::getInstance()->get('validation.level');
     // Default value if validation.level was not specified.
     if (is_array($mode)) {
         $mode = 'log';
     }
     // Check valid validation level
     if (!in_array($mode, array('log', 'strict', 'disabled'))) {
         trigger_error('Invalid validation.level in configuration', E_USER_NOTICE);
     }
     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 BlockCypherModel())) {
                 // Silently return false on cases where you are using BlockCypherModel 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/blockcypher/php-client/issues";
                 BlockCypherLoggingManager::getInstance(__CLASS__)->debug($errorMessage);
                 if ($mode == 'strict') {
                     trigger_error($errorMessage, E_USER_NOTICE);
                 }
                 return false;
             }
         }
         return true;
     }
     return false;
 }
 /**
  * Default Constructor
  *
  * @param ApiContext $apiContext
  */
 public function __construct(ApiContext $apiContext)
 {
     $this->apiContext = $apiContext;
     $this->logger = BlockCypherLoggingManager::getInstance(__CLASS__);
 }
 /**
  * Construct
  *
  * @param null $accessToken
  */
 public function __construct($accessToken)
 {
     $this->accessToken = $accessToken;
     $this->logger = BlockCypherLoggingManager::getInstance(__CLASS__);
 }
 /**
  * Fills object value from Array list
  *
  * @param $arr
  * @return $this
  */
 public function fromArray($arr)
 {
     if (!empty($arr)) {
         // Iterate over each element in array
         foreach ($arr as $k => $v) {
             // If the value is an array, it means, it is an object after conversion
             if (is_array($v)) {
                 // Determine the class of the object
                 if (($clazz = ReflectionUtil::getPropertyClass(get_class($this), $k)) != null) {
                     // If the value is an associative array, it means, its an object. Just make recursive call to it.
                     if (empty($v)) {
                         if (ReflectionUtil::isPropertyClassArray(get_class($this), $k)) {
                             // It means, it is an array of objects.
                             $this->assignValue($k, array());
                             continue;
                         }
                         $o = new $clazz();
                         //$arr = array();
                         $this->assignValue($k, $o);
                     } elseif (ArrayUtil::isAssocArray($v)) {
                         /** @var BlockCypherModel $o */
                         $o = new $clazz();
                         $o->fromArray($v);
                         $this->assignValue($k, $o);
                     } else {
                         // Else, value is an array of object/data
                         $arr = array();
                         // Iterate through each element in that array.
                         foreach ($v as $nk => $nv) {
                             if (is_array($nv)) {
                                 //BlockCypherLoggingManager::getInstance()->debug("new instance of class: $clazz");
                                 if (!class_exists($clazz)) {
                                     BlockCypherLoggingManager::getInstance()->error("Class not found: {$clazz}");
                                 } else {
                                     try {
                                         $o = new $clazz();
                                         $o->fromArray($nv);
                                         $arr[$nk] = $o;
                                     } catch (\Exception $e) {
                                         BlockCypherLoggingManager::getInstance()->error($e->getMessage());
                                     }
                                 }
                             } else {
                                 $arr[$nk] = $nv;
                             }
                         }
                         $this->assignValue($k, $arr);
                     }
                 } else {
                     $this->assignValue($k, $v);
                 }
             } else {
                 $this->assignValue($k, $v);
             }
         }
     }
     return $this;
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $this->object = BlockCypherLoggingManager::getInstance('AddressTest');
 }