protected function getWidgetName(InputInterface $input, OutputInterface $output)
{
$validate = function ($widgetName) {
if (empty($widgetName)) {
throw new \InvalidArgumentException('Please enter the name of your widget');
}
if (preg_match("/[^A-Za-z0-9 ]/", $widgetName)) {
throw new \InvalidArgumentException('Only alpha numerical characters and whitespaces are allowed');
}
return $widgetName;
};
$widgetName = $input->getOption('widgetname');
if (empty($widgetName)) {
$dialog = $this->getHelperSet()->get('dialog');
$widgetName = $dialog->askAndValidate($output, 'Enter the name of your Widget, for instance "Browser Families": ', $validate);
} else {
$validate($widgetName);
}
$widgetName = ucfirst($widgetName);
return $widgetName;
}