private function extractRelationship(RelationshipMetadata $relMeta, $reference)
    {
        $simple  = false === $relMeta->isPolymorphic();
        $idKey   = Persister::IDENTIFIER_KEY;
        $typeKey = Persister::POLYMORPHIC_KEY;

        if (true === $simple && is_array($reference) && isset($reference[$idKey])) {
            return [
                'id'    => $reference[$idKey],
                'type'  => $relMeta->getEntityType(),
            ];
        }

        if (true === $simple && !is_array($reference)) {
            return [
                'id'    => $reference,
                'type'  => $relMeta->getEntityType(),
            ];
        }

        if (false === $simple && is_array($reference) && isset($reference[$idKey]) && isset($reference[$typeKey])) {
            return [
                'id'    => $reference[$idKey],
                'type'  => $reference[$typeKey],
            ];
        }
        throw PersisterException::badRequest('Unable to extract a reference id.');
    }