Plank\Mediable\Helpers\File::cleanDirname PHP 메소드

cleanDirname() 공개 정적인 메소드

Get the directory name of path, trimming unecessary . and / characters.
public static cleanDirname ( string $path ) : string
$path string
리턴 string
    public static function cleanDirname($path)
    {
        $dirname = pathinfo($path, PATHINFO_DIRNAME);
        if ($dirname == '.') {
            return '';
        }
        return trim($dirname, '/');
    }

Usage Example

예제 #1
0
 public function test_it_provides_a_cleaned_dirname()
 {
     $this->assertEquals('', File::cleanDirname(''));
     $this->assertEquals('', File::cleanDirname('/'));
     $this->assertEquals('', File::cleanDirname('foo.jpg'));
     $this->assertEquals('foo', File::cleanDirname('/foo/bar/'));
     $this->assertEquals('foo/bar', File::cleanDirname('/foo/bar/baz.jpg'));
 }
All Usage Examples Of Plank\Mediable\Helpers\File::cleanDirname