original_string: public function addSegment($segment, $other = null){
  		if(!$segment instanceof Segment){
  			$segment = new Segment($segment);
  		}
  		if($this->getIndexOf($segment->getName())) throw new \Exception('Section with this name already exists');
  		if($other){
  			if(($index = $this->getIndexOf($other))===false) throw new \Exception('Segment not found');
  			array_splice($this->segments, $index, 0, [$segment]);
  		}else{
  			$this->segments[] = $segment;
  		}
  		return $segment;
  	}
code: public function addSegment($segment, $other = null){
  		if(!$segment instanceof Segment){
  			$segment = new Segment($segment);
  		}
  		if($this->getIndexOf($segment->getName())) throw new \Exception('Section with this name already exists');
  		if($other){
  			if(($index = $this->getIndexOf($other))===false) throw new \Exception('Segment not found');
  			array_splice($this->segments, $index, 0, [$segment]);
  		}else{
  			$this->segments[] = $segment;
  		}
  		return $segment;
  	}
code_tokens: public function addSegment ( $ segment , $ other = null ) { if ( ! $ segment instanceof Segment ) { $ segment = new Segment ( $ segment ) ; } if ( $ this -> getIndexOf ( $ segment -> getName ( ) ) ) throw new \ Exception ( 'Section with this name already exists' ) ; if ( $ other ) { if ( ( $ index = $ this -> getIndexOf ( $ other ) ) === false ) throw new \ Exception ( 'Segment not found' ) ; array_splice ( $ this -> segments , $ index , 0 , [ $ segment ] ) ; } else { $ this -> segments [ ] = $ segment ; } return $ segment ; }
docstring: Adds a new segment
  @param string|\csslib\Segment $segment Segment to be addded
  @param \csslib\Segment $other If given the segment to be added wil be inserted before the other segment
  @return \csslib\Segment The added segment
docstring_tokens: Adds a new segment