public function through(
        string $variable = null,
        string $type = null,
        string $direction = 'BOTH'
    ): self {
        if ($this->elements->size() < 3) {
            throw new LogicException;
        }

        $direction = \strtolower($direction);

        $path = new self;
        $path->elements = $this
            ->elements
            ->dropEnd(2)
            ->add(Relationship::$direction($variable, $type))
            ->add($this->elements->last());
        $path->lastOperation = Relationship::class;

        return $path;
    }
public function through(
        string $variable = null,
        string $type = null,
        string $direction = 'BOTH'
    ): self {
        if ($this->elements->size() < 3) {
            throw new LogicException;
        }

        $direction = \strtolower($direction);

        $path = new self;
        $path->elements = $this
            ->elements
            ->dropEnd(2)
            ->add(Relationship::$direction($variable, $type))
            ->add($this->elements->last());
        $path->lastOperation = Relationship::class;

        return $path;
    }
public function through ( string $ variable = null , string $ type = null , string $ direction = 'BOTH' ) : self { if ( $ this -> elements -> size ( ) < 3 ) { throw new LogicException ; } $ direction = \ strtolower ( $ direction ) ; $ path = new self ; $ path -> elements = $ this -> elements -> dropEnd ( 2 ) -> add ( Relationship :: $ direction ( $ variable , $ type ) ) -> add ( $ this -> elements -> last ( ) ) ; $ path -> lastOperation = Relationship :: class ; return $ path ; }
Type the last declared relationship in the path

@param string $variable
@param string $type
@param string $direction

@throws LogicException If no relationship in the path

@return self
Type the last declared relationship in the path