code: private function buildEntity(ClassMetadata $metadata, $data)
      {
          $class = $metadata->getName();
          $entity = new $class;
  
          foreach ($data as $propertyPath => $value) {
              // Field
              if ($metadata->hasField($propertyPath)) {
                  $builtValue = $this->buildFieldValue($metadata, $propertyPath, $value);
  
              // Association
              } elseif ($metadata->hasAssociation($propertyPath)) {
                  $builtValue = $this->buildAssociationValue($metadata, $propertyPath, $value);
  
              } else {
                  throw new \Exception("Unexpected property path '$propertyPath' for class '$class'.");
              }
  
              $this->accessor->setValue($entity, $propertyPath, $builtValue);
          }
  
          return $entity;
      }
docs: Builds the entity
  
  @param ClassMetadata $metadata
  @param array         $data
  
  @return object
  @throws \Exception