original_string: 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;
      }
code: 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;
      }
code_tokens: 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 ; }
docstring: 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
docstring_tokens: Type the last declared relationship in the path