Пример #1
0
 public static function findHereOrInParent($frag, $start, SystemLocals $locals = null)
 {
     if (!is_string($frag)) {
         throw new \InvalidArgumentException('Frag must be a string');
     }
     if (!is_string($start)) {
         throw new \InvalidArgumentException('Start must be a string');
     }
     if (empty($locals)) {
         $locals = new SystemLocals();
     }
     $start = self::homeify($start, $locals);
     if (!file_exists($start)) {
         throw new \InvalidArgumentException('Start must be a valid path to a file or directory');
     }
     if (!is_dir($start)) {
         $start = dirname($start);
     }
     $dir = PathUtils::untrailslashit($start);
     $frag = PathUtils::unleadslashit($frag);
     while (!file_exists($dir . DIRECTORY_SEPARATOR . $frag) && '/' !== $dir) {
         $dir = dirname($dir);
     }
     return $dir == '/' ? false : realpath($dir . DIRECTORY_SEPARATOR . $frag);
 }
Пример #2
0
 /**
  * @test
  * it should allow unleadslash paths
  * @dataProvider unleadslashPaths
  */
 public function it_should_allow_unleadslash_paths($path, $expected)
 {
     $this->assertEquals($expected, PathUtils::unleadslashit($path));
 }