/**
  * Asks the type of an association.
  *
  * @param InputInterface    $input
  * @param OutputInterface   $output
  * @param ClassMetadata $metadata
  * @param string            $associationName
  *
  * @return string
  */
 private function askAssociationType(GeneratorStyle $io, ClassMetadata $metadata, $associationName = null)
 {
     // Get supported Doctrine association types.
     $types = $metadata->getSupportedAssociationTypes();
     // Get actual field unique based on field name
     // or default value if not set.
     $type = $metadata->getAssociationType($associationName) ?: static::DEFAULT_TYPE;
     // Create new question
     return $io->ask('Please enter the association type', $type, function ($answer) use($types) {
         if (empty($answer)) {
             return;
         }
         if (!in_array($answer, $types)) {
             throw new \InvalidArgumentException(sprintf('Invalid association type "%s".', $answer));
         }
         return $answer;
     });
 }