protected function mergePaths(URI $base, URI $reference): string
	{
		if (! empty($base->getAuthority()) && empty($base->getPath()))
		{
			return '/' . ltrim($reference->getPath(), '/ ');
		}

		$path = explode('/', $base->getPath());

		if (empty($path[0]))
		{
			unset($path[0]);
		}

		array_pop($path);
		array_push($path, $reference->getPath());

		return implode('/', $path);
	}
protected function mergePaths(URI $base, URI $reference): string
	{
		if (! empty($base->getAuthority()) && empty($base->getPath()))
		{
			return '/' . ltrim($reference->getPath(), '/ ');
		}

		$path = explode('/', $base->getPath());

		if (empty($path[0]))
		{
			unset($path[0]);
		}

		array_pop($path);
		array_push($path, $reference->getPath());

		return implode('/', $path);
	}
protected function mergePaths ( URI $ base , URI $ reference ) : string { if ( ! empty ( $ base -> getAuthority ( ) ) && empty ( $ base -> getPath ( ) ) ) { return '/' . ltrim ( $ reference -> getPath ( ) , '/ ' ) ; } $ path = explode ( '/' , $ base -> getPath ( ) ) ; if ( empty ( $ path [ 0 ] ) ) { unset ( $ path [ 0 ] ) ; } array_pop ( $ path ) ; array_push ( $ path , $ reference -> getPath ( ) ) ; return implode ( '/' , $ path ) ; }
Given 2 paths, will merge them according to rules set out in RFC 2986,
Section 5.2

@see http://tools.ietf.org/html/rfc3986#section-5.2.3

@param URI $base
@param URI $reference

@return string
Given 2 paths will merge them according to rules set out in RFC 2986 Section 5 . 2