public function __invoke($fieldName, Field $field, ClassMetadata $metadata, $extraOptions = [])
 {
     $type = $field->getStorageType();
     $options = $field->getStorageOptions();
     $extraOptions = array_merge(['serialize_scalar' => false], $extraOptions);
     if (true === $extraOptions['serialize_scalar']) {
         $metadata->mapField(['fieldName' => $fieldName, 'type' => 'array']);
         return;
     }
     if ($type === Type\ObjectType::class) {
         $metadata->mapField(['fieldName' => $fieldName, 'type' => 'object']);
         return;
     }
     if ($type === Type\BooleanType::class) {
         $metadata->mapField(['fieldName' => $fieldName, 'type' => 'boolean', 'nullable' => true]);
         return;
     }
     if ($type === Type\DoubleType::class) {
         $metadata->mapField(['fieldName' => $fieldName, 'type' => 'float', 'nullable' => true]);
         return;
     }
     if ($type === Type\CollectionType::class) {
         $this->mapCollectionType($fieldName, $field, $metadata);
         return;
     }
     if ($type === Type\StringType::class) {
         $metadata->mapField(['fieldName' => $fieldName, 'type' => 'string', 'nullable' => true]);
         return;
     }
     if ($type === Type\IntegerType::class) {
         $metadata->mapField(['fieldName' => $fieldName, 'type' => 'integer', 'nullable' => true]);
         return;
     }
     if ($type === Type\DateTimeType::class) {
         $metadata->mapField(['fieldName' => $fieldName, 'type' => 'date', 'nullable' => true]);
         return;
     }
     if ($type === Type\ReferenceType::class) {
         if (false === isset($options['class'])) {
             throw new \InvalidArgumentException(sprintf('Doctrine ORM storage requires that you provide the "class" option for reference mapping for "%s::$%s"', $metadata->getName(), $fieldName));
         }
         $metadata->mapManyToOne(['fieldName' => $fieldName, 'targetEntity' => $options['class'], 'cascade' => ['all']]);
         return;
     }
     throw new \RuntimeException(sprintf('Do not know how to map field of type "%s"', $type));
 }
 public function __invoke($fieldName, Field $field, ClassMetadata $metadata, array $extraOptions = [])
 {
     $type = $field->getStorageType();
     $options = array_merge(['multivalue' => false], $extraOptions);
     if ($type === Type\ObjectType::class) {
         $options = $field->getStorageOptions();
         $this->unrestrictChildClass($options['class'], $metadata);
         $metadata->mapChild(['fieldName' => $fieldName, 'nodeName' => $this->encoder->encode($fieldName), 'nullable' => true]);
         return;
     }
     if ($type === Type\CollectionType::class) {
         $this->mapCollectionType($fieldName, $field, $metadata);
         return;
     }
     if ($type === Type\StringType::class) {
         $metadata->mapField(['fieldName' => $fieldName, 'type' => 'string', 'nullable' => true, 'multivalue' => $options['multivalue']]);
         return;
     }
     if ($type === Type\IntegerType::class) {
         $metadata->mapField(['fieldName' => $fieldName, 'type' => 'long', 'nullable' => true, 'multivalue' => $options['multivalue']]);
         return;
     }
     if ($type === Type\BooleanType::class) {
         $metadata->mapField(['fieldName' => $fieldName, 'type' => 'boolean', 'nullable' => true]);
         return;
     }
     if ($type === Type\DoubleType::class) {
         $metadata->mapField(['fieldName' => $fieldName, 'type' => 'double', 'nullable' => true]);
         return;
     }
     if ($type === Type\DateTimeType::class) {
         $metadata->mapField(['fieldName' => $fieldName, 'type' => 'date', 'nullable' => true, 'multivalue' => $options['multivalue']]);
         return;
     }
     if ($type === Type\ReferenceType::class) {
         $metadata->mapManyToOne(['fieldName' => $fieldName, 'strategy' => 'hard', 'nullable' => true, 'cascade' => ClassMetadata::CASCADE_ALL, 'multivalue' => $options['multivalue']]);
         return;
     }
     throw new \RuntimeException(sprintf('Do not know how to map field of type "%s"', $type));
 }