/**
  * Asks the name of an association.
  *
  * @param InputInterface    $input
  * @param OutputInterface   $output
  * @param ClassMetadata $metadata
  * @param string            $associationName
  *
  * @return string
  */
 private function askAssociationName(GeneratorStyle $io, ClassMetadata $metadata, $associationName = null)
 {
     // Create new question
     return $io->ask('Please enter the association name', $associationName, function ($answer) use($metadata, $associationName) {
         // if provided association name
         // is not the same as default field name
         if ($answer !== $associationName) {
             // Validate that the field name
             // is not already used in mapping.
             /* @throws Doctrine\ORM\Mapping\MappingException */
             $metadata->assertFieldNotMapped($answer);
         }
         return $answer;
     });
 }