src/Hydrator.php
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.');
    }
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.');
    }
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.' ) ; }
Extracts a standard relationship array that the store expects from a raw MongoDB reference value.

@param   RelationshipMetadata    $relMeta
@param   mixed                   $reference
@return  array
@throws  RuntimeException        If the relationship could not be extracted.
Extracts a standard relationship array that the store expects from a raw MongoDB reference value .