/**
* Validates the new configuration option against its
* default value to ensure it's the correct type.
*
* If an invalid type is given, an exception is thrown.
*
* @param string $key
* @param mixed $value
*
* @return bool
*
* @throws ConfigurationException
*/
protected function validate($key, $value)
{
$default = $this->get($key);
if (is_array($default)) {
$validator = new ArrayValidator($key, $value);
} elseif (is_int($default)) {
$validator = new IntegerValidator($key, $value);
} elseif (is_bool($default)) {
$validator = new BooleanValidator($key, $value);
} else {
$validator = new StringValidator($key, $value);
}
return $validator->validate();
}