/**
  * @param              $object
  * @param Relationship $relationship
  * @param Context      $context
  *
  * @return array
  */
 protected function processRelationship($object, Relationship $relationship, Context $context)
 {
     if (null === $object) {
         return null;
     }
     if (!is_object($object)) {
         throw new \RuntimeException(sprintf('Cannot process relationship "%s", because it is not an object but a %s.', $relationship->getName(), gettype($object)));
     }
     /** @var ClassMetadata $relationshipMetadata */
     $relationshipMetadata = $this->hateoasMetadataFactory->getMetadataForClass(get_class($object));
     if (null === $relationshipMetadata) {
         throw new \RuntimeException(sprintf('Metadata for class %s not found. Did you define at as a JSON-API resource?', ClassUtils::getRealClass(get_class($object))));
     }
     $relationshipId = $this->getId($relationshipMetadata, $object);
     // contains the relations type and id
     $relationshipDataArray = $this->getRelationshipDataArray($relationshipMetadata, $relationshipId);
     // only include this relationship if it is needed
     if ($relationship->isIncludedByDefault() && $this->canIncludeRelationship($relationshipMetadata, $relationshipId)) {
         $includedRelationship = $relationshipDataArray;
         // copy data array so we do not override it with our reference
         $this->includedRelationships[] =& $includedRelationship;
         $includedRelationship = $context->accept($object);
         // override previous reference with the serialized data
     }
     // the relationship data can only contain one reference to another resource
     return $relationshipDataArray;
 }