protected function retrieveDirected(Direction $direction, ID $node_id, string $class): \ArrayIterator
    {
        $key = $direction->equals(Direction::in()) ? "from" : "to";
        $direction = (string) $direction;

        $hydrate = function (EncapsulatedEdge $encapsulated): EdgeInterface {
            if(!$encapsulated->hydrated())
                return $this->master->edge($encapsulated->id());
            return $encapsulated->edge();
        };

        $filter_classes = function (EncapsulatedEdge $encapsulated) use ($class): bool {
            return in_array($class, $encapsulated->classes());
        };

        if(!isset($this->$key[(string) $node_id])) { 
            return new \ArrayIterator();
        }
        
        if(empty($class)) {
            return new \ArrayIterator(
                array_map($hydrate, $this->$key[(string) $node_id])
            );
        }
        
        return new \ArrayIterator(
            array_map($hydrate, array_filter($this->$key[(string) $node_id], $filter_classes))
        );
    }
protected function retrieveDirected(Direction $direction, ID $node_id, string $class): \ArrayIterator
    {
        $key = $direction->equals(Direction::in()) ? "from" : "to";
        $direction = (string) $direction;

        $hydrate = function (EncapsulatedEdge $encapsulated): EdgeInterface {
            if(!$encapsulated->hydrated())
                return $this->master->edge($encapsulated->id());
            return $encapsulated->edge();
        };

        $filter_classes = function (EncapsulatedEdge $encapsulated) use ($class): bool {
            return in_array($class, $encapsulated->classes());
        };

        if(!isset($this->$key[(string) $node_id])) { 
            return new \ArrayIterator();
        }
        
        if(empty($class)) {
            return new \ArrayIterator(
                array_map($hydrate, $this->$key[(string) $node_id])
            );
        }
        
        return new \ArrayIterator(
            array_map($hydrate, array_filter($this->$key[(string) $node_id], $filter_classes))
        );
    }
protected function retrieveDirected ( Direction $ direction , ID $ node_id , string $ class ) : \ ArrayIterator { $ key = $ direction -> equals ( Direction :: in ( ) ) ? "from" : "to" ; $ direction = ( string ) $ direction ; $ hydrate = function ( EncapsulatedEdge $ encapsulated ) : EdgeInterface { if ( ! $ encapsulated -> hydrated ( ) ) return $ this -> master -> edge ( $ encapsulated -> id ( ) ) ; return $ encapsulated -> edge ( ) ; } ; $ filter_classes = function ( EncapsulatedEdge $ encapsulated ) use ( $ class ) : bool { return in_array ( $ class , $ encapsulated -> classes ( ) ) ; } ; if ( ! isset ( $ this -> $ key [ ( string ) $ node_id ] ) ) { return new \ ArrayIterator ( ) ; } if ( empty ( $ class ) ) { return new \ ArrayIterator ( array_map ( $ hydrate , $ this -> $ key [ ( string ) $ node_id ] ) ) ; } return new \ ArrayIterator ( array_map ( $ hydrate , array_filter ( $ this -> $ key [ ( string ) $ node_id ] , $ filter_classes ) ) ) ; }
A helper method to retrieve directed edges.

@see from A method that uses this function
@see to A method that uses this function

@param Direction $direction Lets you choose to fetch incoming or outgoing edges.
@param ID        $node_id   Directed towards which node.
@param string    $class     The type of edge (defined in edge class) to return.

@return \ArrayIterator An array of EdgeInterface objects.
A helper method to retrieve directed edges .