relativizeFrom() 공개 메소드

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
 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;
 }