relativizeFrom() public method

public relativizeFrom ( path $reference )
$reference path
コード例 #1
0
ファイル: compiler.php プロジェクト: xihewang/atoum
 protected function doRun()
 {
     $data = array();
     $srcDirectory = new atoum\fs\path($this->srcDirectory);
     foreach (new iterators\recursives\atoum\source($this->srcDirectory) as $file) {
         $file = new atoum\fs\path($file);
         $data[(string) $file->relativizeFrom($srcDirectory)] = file_get_contents($file);
     }
     $bootstrapFile = new atoum\fs\path($this->bootstrapFile);
     $bootstrapFile = $bootstrapFile->relativizeFrom($srcDirectory);
     $bootstrap = '<?php $directory = sys_get_temp_dir() . \'/\' . basename(__FILE__);';
     $bootstrap .= '$bootstrap = $directory . \'/' . $bootstrapFile . '\';';
     $bootstrap .= 'if (is_file($bootstrap) === false || filemtime(__FILE__) > filemtime($bootstrap))';
     $bootstrap .= '{';
     $bootstrap .= '$data = eval(substr(file_get_contents(__FILE__), __COMPILER_HALT_OFFSET__));';
     $bootstrap .= 'foreach ($data as $file => $contents)';
     $bootstrap .= '{';
     $bootstrap .= '$file = $directory . \'/\' . $file;';
     $bootstrap .= '@mkdir(dirname($file), 0777, true);';
     $bootstrap .= '@file_put_contents($file, $contents);';
     $bootstrap .= '}';
     $bootstrap .= '}';
     $bootstrap .= 'require $bootstrap;';
     $bootstrap .= '__halt_compiler();';
     if (file_put_contents($this->destinationFile, $bootstrap . 'return ' . var_export($data, true) . ';') === false) {
         throw new exceptions\runtime(sprintf($this->locale->_('Unable to write in file \'%s\''), $this->destinationFile));
     }
     return $this;
 }
コード例 #2
0
ファイル: Custom.php プロジェクト: cubiche/tests
 /**
  * @param Path $path
  *
  * @return string
  */
 protected function getFileName(Path $path)
 {
     return ltrim((string) $path->relativizeFrom($this->sourceDirectory), './');
 }
コード例 #3
0
ファイル: path.php プロジェクト: andrewolobo/mpTracker
 public function testRelativizeFrom($path, $directorySeparator, $fromPath, $fromDirectorySeparator, $relativePath)
 {
     $this->if($path = new testedClass($path, $directorySeparator))->then->object($path->relativizeFrom(new testedClass($fromPath, $fromDirectorySeparator)))->isIdenticalTo($path)->toString->isEqualTo($relativePath);
 }
コード例 #4
0
ファイル: coveralls.php プロジェクト: atoum/atoum
 protected function makeSourceElement(score\coverage $coverage)
 {
     $sources = array();
     foreach ($coverage->getClasses() as $class => $file) {
         $path = new atoum\fs\path($file);
         $source = $this->adapter->file_get_contents((string) $path->resolve());
         $sources[] = array('name' => ltrim((string) $path->relativizeFrom($this->sourceDir), '.' . DIRECTORY_SEPARATOR), 'source' => $source, 'coverage' => $this->makeCoverageElement($coverage->getCoverageForClass($class)));
     }
     return $sources;
 }