PhpSpec\Console\ConsoleIO::askConfirmation PHP Метод

askConfirmation() публичный Метод

public askConfirmation ( string $question, boolean $default = true ) : boolean
$question string
$default boolean
Результат boolean
    public function askConfirmation($question, $default = true)
    {
        $lines = array();
        $lines[] = '<question>' . str_repeat(' ', $this->getBlockWidth()) . "</question>";
        foreach (explode("\n", wordwrap($question, $this->getBlockWidth() - 4, "\n", true)) as $line) {
            $lines[] = '<question>  ' . str_pad($line, $this->getBlockWidth() - 2) . '</question>';
        }
        $lines[] = '<question>' . str_repeat(' ', $this->getBlockWidth() - 8) . '</question> <value>' . ($default ? '[Y/n]' : '[y/N]') . '</value> ';
        $formattedQuestion = implode("\n", $lines) . "\n";
        return $this->prompter->askConfirmation($formattedQuestion, $default);
    }

Usage Example

 /**
  * @param SuiteEvent $event
  */
 public function afterSuite(SuiteEvent $event)
 {
     if (!$this->io->isCodeGenerationEnabled()) {
         return;
     }
     foreach ($this->exceptions as $exception) {
         $resource = $this->resources->createResource($exception->getCollaboratorName());
         if ($this->resourceIsInSpecNamespace($exception, $resource)) {
             continue;
         }
         if ($this->io->askConfirmation(sprintf('Would you like me to generate an interface `%s` for you?', $exception->getCollaboratorName()))) {
             $this->generator->generate($resource, 'interface');
             $event->markAsWorthRerunning();
         }
     }
 }
All Usage Examples Of PhpSpec\Console\ConsoleIO::askConfirmation