isRelative() public static method

Returns whether a path is relative.
Since: 1.0 Added method.
Since: 2.0 Method now fails if $path is not a string.
public static isRelative ( string $path ) : boolean
$path string A path string.
return boolean Returns true if the path is relative or empty, false if it is absolute.
 private function fixSuitePath($fix_path)
 {
     $xpath = new DOMXPath($this->doc);
     $node_list = $xpath->query('//testsuite/directory | //testsuite/file | //testsuite/exclude');
     foreach ($node_list as $node) {
         if (Path::isRelative($path = $node->textContent)) {
             $new_text = new DOMText(Path::canonicalize($fix_path . '/' . $path));
             if ($node->firstChild) {
                 $node->replaceChild($new_text, $node->firstChild);
             } else {
                 $node->appendChild($new_text);
             }
         }
     }
 }
示例#2
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage The path must be a string. Got: array
  */
 public function testIsRelativeFailsIfInvalidPath()
 {
     Path::isRelative(array());
 }
示例#3
0
 /**
  * Process given dir with replacements and makes it absolute.
  *
  * @param string $dir
  *
  * @return string
  *   Absolute path with placeholders replaced.
  */
 protected function processDir($dir)
 {
     $dir = $this->replacePattern($dir);
     // The absolute path has to be calculated relative to the configuration file
     if (Path::isRelative($dir)) {
         $dir = Path::makeAbsolute($dir, dirname($this->configFile));
     }
     return rtrim($dir, '/');
 }