You are here

private static function Braintree_Configuration::validate in Commerce Braintree 7

performs sanity checks when config settings are being set

@ignore @access protected

@static

Parameters

string $key name of config setting:

string $value value to set:

Return value

boolean

Throws

InvalidArgumentException

Braintree_Exception_Configuration

1 call to Braintree_Configuration::validate()
Braintree_Configuration::set in braintree_php/lib/Braintree/Configuration.php

File

braintree_php/lib/Braintree/Configuration.php, line 79

Class

Braintree_Configuration
acts as a registry for config data.

Code

private static function validate($key = null, $value = null) {
  if (empty($key) && empty($value)) {
    throw new InvalidArgumentException('nothing to validate');
  }
  if ($key === 'environment' && !in_array($value, self::$_validEnvironments)) {
    throw new Braintree_Exception_Configuration('"' . $value . '" is not a valid environment.');
  }
  if (!isset(self::$_cache[$key])) {
    throw new Braintree_Exception_Configuration($key . ' is not a valid configuration setting.');
  }
  if (empty($value)) {
    throw new InvalidArgumentException($key . ' cannot be empty.');
  }
  return true;
}