getLongestCommonBasePath() public static method

Dot segments ("." and "..") are removed/collapsed and all slashes turned into forward slashes. php $basePath = Path::getLongestCommonBasePath(array( '/webmozart/css/style.css', '/webmozart/css/..' )); => /webmozart The root is returned if no common base path can be found: php $basePath = Path::getLongestCommonBasePath(array( '/webmozart/css/style.css', '/puli/css/..' )); => / If the paths are located on different Windows partitions, null is returned. php $basePath = Path::getLongestCommonBasePath(array( 'C:/webmozart/css/style.css', 'D:/webmozart/css/..' )); => null
Since: 1.0 Added method.
Since: 2.0 Method now fails if $paths are not strings.
public static getLongestCommonBasePath ( array $paths ) : string | null
$paths array A list of paths.
return string | null The longest common base path in canonical form or `null` if the paths are on different Windows partitions.
Ejemplo n.º 1
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage The paths must be strings. Got: array
  */
 public function testGetLongestCommonBasePathFailsIfInvalidPath()
 {
     Path::getLongestCommonBasePath(array(array()));
 }