original_string: public function resolve($path)
  	{
  		if ($path instanceof Path) {
  			$add = clone $path;
  		} else if (is_string($path)) {
  			$add = new Path($path);
  		} else {
  			throw new \InvalidArgumentException();
  		}
  		
  		$base = clone $this;
  		
  		if ($base->partCount === 0) {
  			return $add;
  		}
  		if ($add->isAbsolute()) {
  			return $add;
  		}
  		if ($base->lastPart === '') {
  			array_pop($base->parts);
  		}
  		if ($add->firstPart === '') {
  			array_shift($add->parts);
  		}
  		foreach ($add->parts as $part) {
  			$base->parts[] = $part;
  		}
  		if ($add->partCount === 0) {
  			$base->parts[] = '';
  		}
  		$base->setParts($base->parts);
  		return $base;
  	}
code: public function resolve($path)
  	{
  		if ($path instanceof Path) {
  			$add = clone $path;
  		} else if (is_string($path)) {
  			$add = new Path($path);
  		} else {
  			throw new \InvalidArgumentException();
  		}
  		
  		$base = clone $this;
  		
  		if ($base->partCount === 0) {
  			return $add;
  		}
  		if ($add->isAbsolute()) {
  			return $add;
  		}
  		if ($base->lastPart === '') {
  			array_pop($base->parts);
  		}
  		if ($add->firstPart === '') {
  			array_shift($add->parts);
  		}
  		foreach ($add->parts as $part) {
  			$base->parts[] = $part;
  		}
  		if ($add->partCount === 0) {
  			$base->parts[] = '';
  		}
  		$base->setParts($base->parts);
  		return $base;
  	}
code_tokens: public function resolve ( $ path ) { if ( $ path instanceof Path ) { $ add = clone $ path ; } else if ( is_string ( $ path ) ) { $ add = new Path ( $ path ) ; } else { throw new \ InvalidArgumentException ( ) ; } $ base = clone $ this ; if ( $ base -> partCount === 0 ) { return $ add ; } if ( $ add -> isAbsolute ( ) ) { return $ add ; } if ( $ base -> lastPart === '' ) { array_pop ( $ base -> parts ) ; } if ( $ add -> firstPart === '' ) { array_shift ( $ add -> parts ) ; } foreach ( $ add -> parts as $ part ) { $ base -> parts [ ] = $ part ; } if ( $ add -> partCount === 0 ) { $ base -> parts [ ] = '' ; } $ base -> setParts ( $ base -> parts ) ; return $ base ; }
docstring: Adds a path to the current path and returns the new path object.
  
  Example: Resolving 'foo/bar' from the path '/dir' produces '/dir/foo/bar'.
  
  Noteworthy special cases:
  - If the path to resolve is absolute, this absolute path is returned and our current base is dropped.
  - If the path to resolve is empty, a slash is added to the current path if not already present.
  - We do not know if our path is a directory or not. Resolving 'dir' from '/file' results in '/file/dir'.
  
  @param string|Path $path
  @return static a new Path object
docstring_tokens: Adds a path to the current path and returns the new path object .