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);
}