public function afterExample(ExampleEvent $event)
{
$exception = $event->getException();
if (null !== $exception && $exception instanceof ClassNotFoundException) {
if (in_array($exception->getClassname(), $this->proposedClasses)) {
return;
}
$this->proposedClasses[] = $exception->getClassname();
if (null === ($ioTemp = $this->io->cutTemp())) {
if ("\n" !== $this->io->getLastWrittenMessage()) {
$this->io->writeln();
}
}
if ($this->io->askConfirmation('Do you want me to create this class for you?')) {
$classname = $exception->getClassname();
$filepath = $this->path . str_replace('\\', DIRECTORY_SEPARATOR, $classname) . '.php';
$path = dirname($filepath);
if (!is_dir($path)) {
mkdir($path, 0777, true);
}
file_put_contents($filepath, $this->getClassContentFor($classname));
$this->io->writeln(sprintf("\n<info>class <value>%s</value> has been created.</info>", $classname), 6);
}
$this->io->writeln();
if (null !== $ioTemp) {
$this->io->writeTemp($ioTemp);
}
}
}