public function __construct($name, $options = array())
{
$this->name = $name;
// Check for invalid option
$invalidOptions = array_diff(array_keys($options), array_keys(self::$defaults));
if (count($invalidOptions) > 0) {
throw new \Exception('Invalid config option(s) [' . implode(', ', $invalidOptions) . ']');
}
// Set a default false for confirmation
if (isset($options['type']) && $options['type'] == 'confirmation') {
$options['default'] = false;
}
// Merging with defaults
$this->options = array_merge(self::$defaults, $options);
// Type validation
if (!in_array($this->options['type'], self::$validTypes)) {
throw new \Exception('Invalid option type [' . $this->options['type'] . ']');
}
}