original_string: public function withInserted(int $idx, Element $el): self
      {
          if (count($this->_elements) < $idx || $idx < 0) {
              throw new \OutOfBoundsException("Index $idx is out of bounds.");
          }
          $obj = clone $this;
          array_splice($obj->_elements, $idx, 0, [$el]);
          return $obj;
      }
code: public function withInserted(int $idx, Element $el): self
      {
          if (count($this->_elements) < $idx || $idx < 0) {
              throw new \OutOfBoundsException("Index $idx is out of bounds.");
          }
          $obj = clone $this;
          array_splice($obj->_elements, $idx, 0, [$el]);
          return $obj;
      }
code_tokens: public function withInserted ( int $ idx , Element $ el ) : self { if ( count ( $ this -> _elements ) < $ idx || $ idx < 0 ) { throw new \ OutOfBoundsException ( "Index $idx is out of bounds." ) ; } $ obj = clone $ this ; array_splice ( $ obj -> _elements , $ idx , 0 , [ $ el ] ) ; return $ obj ; }
docstring: Get self with an element inserted before the given index.
  
  @param int $idx Element index
  @param Element $el New element to insert into the structure
  @throws \OutOfBoundsException
  @return self
docstring_tokens: Get self with an element inserted before the given index .