public function create($class)
 {
     $reflectionClass = new \ReflectionClass($class);
     $annotation = $this->reader->getClassAnnotation($reflectionClass, RelationshipEntity::class);
     $entityIdMetadata = null;
     $startNodeMetadata = null;
     $endNodeMetadata = null;
     $propertiesMetadata = [];
     $startNodeKey = null;
     $endNodeKey = null;
     foreach ($reflectionClass->getProperties() as $reflectionProperty) {
         if (null === $entityIdMetadata && null !== ($idAnnotation = $this->reader->getPropertyAnnotation($reflectionProperty, GraphId::class))) {
             $entityIdMetadata = new EntityIdMetadata($reflectionProperty->getName(), $reflectionProperty, new IdAnnotationMetadata());
             continue;
         }
         if (null === $startNodeMetadata && null !== ($startAnnotation = $this->reader->getPropertyAnnotation($reflectionProperty, StartNode::class))) {
             $startNodeClass = ClassUtils::getFullClassName($startAnnotation->targetEntity, $class);
             $startNodeMetadata = $startNodeClass;
             $startNodeKey = $reflectionProperty->getName();
             continue;
         }
         if (null === $endNodeMetadata && null !== ($endAnnotation = $this->reader->getPropertyAnnotation($reflectionProperty, EndNode::class))) {
             $endNodeClass = ClassUtils::getFullClassName($endAnnotation->targetEntity, $class);
             $endNodeMetadata = $endNodeClass;
             $endNodeKey = $reflectionProperty->getName();
             continue;
         }
         if (null !== ($propertyAnnotation = $this->reader->getPropertyAnnotation($reflectionProperty, Property::class))) {
             $propertiesMetadata[] = new EntityPropertyMetadata($reflectionProperty->getName(), $reflectionProperty, $this->propertyAnnotationMetadataFactory->create($class, $reflectionProperty->getName()));
         }
     }
     return new RelationshipEntityMetadata($class, $reflectionClass, $annotation, $entityIdMetadata, $startNodeMetadata, $startNodeKey, $endNodeMetadata, $endNodeKey, $propertiesMetadata);
 }
 public function getCreateQuery($entity, $pov)
 {
     $class = ClassUtils::getFullClassName(get_class($entity), $pov);
     $relationshipEntityMetadata = $this->em->getRelationshipEntityMetadata($class);
     $startNode = $relationshipEntityMetadata->getStartNodeValue($entity);
     $startNodeId = $this->em->getClassMetadataFor(get_class($startNode))->getIdValue($startNode);
     $endNode = $relationshipEntityMetadata->getEndNodeValue($entity);
     $endNodeId = $this->em->getClassMetadataFor(get_class($endNode))->getIdValue($endNode);
     $relType = $this->classMetadata->getType();
     $parameters = ['a' => $startNodeId, 'b' => $endNodeId, 'fields' => []];
     foreach ($this->classMetadata->getPropertiesMetadata() as $propertyMetadata) {
         $v = $propertyMetadata->getValue($entity);
         $parameters['fields'][$propertyMetadata->getPropertyName()] = $v;
     }
     $query = 'MATCH (a), (b) WHERE id(a) = {a} AND id(b) = {b}' . PHP_EOL;
     $query .= sprintf('CREATE (a)-[r:%s]->(b)', $relType) . PHP_EOL;
     if (!empty($parameters['fields'])) {
         $query .= 'SET r += {fields} ';
     }
     $query .= 'RETURN id(r) as id';
     return Statement::create($query, $parameters);
 }
 private function hydrateQueryRecord(QueryResultMapper $resultMapper, Record $record)
 {
     $reflClass = new \ReflectionClass($resultMapper->getClassName());
     $instance = $reflClass->newInstanceWithoutConstructor();
     foreach ($resultMapper->getFields() as $field) {
         if (!$record->hasValue($field->getFieldName())) {
             throw new \RuntimeException(sprintf('The record doesn\'t contain the required field "%s"', $field->getFieldName()));
         }
         $value = null;
         if ($field->isEntity()) {
             $value = $this->hydrate($record, false, $field->getFieldName(), ClassUtils::getFullClassName($field->getTarget(), $resultMapper->getClassName()));
         } else {
             $value = $record->get($field->getFieldName());
         }
         $property = $reflClass->getProperty($field->getFieldName());
         $property->setAccessible(true);
         $property->setValue($instance, $value);
     }
     return $instance;
 }
 /**
  * @return string
  */
 public function getRelationshipEntityClass()
 {
     return ClassUtils::getFullClassName($this->relationshipAnnotation->relationshipEntity, $this->className);
 }
 public function getResultMappingMetadata($class)
 {
     if (!array_key_exists($class, $this->resultMappers)) {
         $this->resultMappers[$class] = $this->annotationDriver->readQueryResult($class);
         foreach ($this->resultMappers[$class]->getFields() as $field) {
             if ($field->isEntity()) {
                 $targetFQDN = ClassUtils::getFullClassName($field->getTarget(), $class);
                 $field->setMetadata($this->getClassMetadataFor($targetFQDN));
             }
         }
     }
     return $this->resultMappers[$class];
 }
 /**
  * @return string
  */
 public function getRepositoryClass()
 {
     if (null === $this->customRepository) {
         throw new \LogicException(sprintf('There is no custom repository for "%s"', $this->className));
     }
     return ClassUtils::getFullClassName($this->customRepository, $this->className);
 }