code: public function createMetadata(array $alias)
      {
          $metadata = $this->manager->getMetadataForClassName($alias['class']);
          $aliasedMetadata = new Metadata($metadata->getObjectIdentifier());
  
          foreach ($metadata->getRelations() as $relation) {
              if (array_key_exists($relation->getField(), $alias['mapping'])) {
                  $aliasedMetadata->setRelation(
                      $this->createAliasedRelation(
                          $alias['mapping'][$relation->getField()],
                          $relation
                      )
                  );
              } else {
                  $aliasedMetadata->setRelation($relation);
              }
          }
  
          return $aliasedMetadata;
      }
docs: @param array $alias
  
  @return Metadata
  
  @throws MetadataNotFoundException