/** * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output) { $naming = new Naming(); $helper = $this->getHelper('question'); $options = []; foreach (['block' => 'Block name: ', 'elem' => 'Element name: ', 'modName' => 'Modifier name: ', 'modVal' => 'Modifier value: '] as $name => $q) { $question = new Question($q); while (true) { $value = $helper->ask($input, $output, $question); if ($value === null || preg_match('/^' . $naming->getWordPattern() . '$/', $value)) { $options[$name] = $value; break 1; } else { $output->writeln('<error>' . $value . ' is not valid' . '</error>'); } } } if (($str = (new Naming())->stringify($options)) === null) { throw new \Exception('can\'t create'); } $output->writeln("<info>{$str}</info>"); }