예제 #1
0
파일: PathTest.php 프로젝트: crodas/path
 public function testPaths()
 {
     $path = Path::getRelative(__FILE__, __DIR__);
     $this->assertEquals($path, "/tests/PathTest.php");
     $path = Path::getRelative(__FILE__, __FILE__);
     $this->assertEquals($path, "/PathTest.php");
     $path = Path::getRelative(__FILE__, __DIR__ . "/../lib/crodas/Path.php");
     $this->assertEquals($path, "/../../tests/PathTest.php");
 }
예제 #2
0
 public static function getRelativePath($dir1, $dir2 = NULL)
 {
     if (empty($dir2)) {
         $dir2 = self::$cdir;
     }
     if (substr($dir1, 0, 4) == "/../") {
         // already relative path
         return $dir1;
     }
     return Path::getRelative($dir1, $dir2);
 }
예제 #3
0
 protected function getTemplateArgs($file = "", $default = array())
 {
     $args = array('classes', 'relative', 'deps', 'include_psr0', 'stats', 'hasTraits', 'hasInterface', 'includes');
     $return = array();
     foreach ($args as $arg) {
         $return[$arg] = array_key_exists($arg, $default) ? $default[$arg] : $this->{$arg};
     }
     $return['relative'] = $return['relative'] && !empty($file);
     if ($return['relative']) {
         foreach ($return['classes'] as $class => $fileClass) {
             $return['classes'][$class][0] = Path::getRelative($fileClass[0], $file);
         }
         foreach ($return['includes'] as $id => $include) {
             $return['includes'][$id] = Path::getRelative($include, $file);
         }
     }
     return $return;
 }