dirname() public static method

public static dirname ( string $path ) : string
$path string
return string
Exemplo n.º 1
0
 /**
  * Save an image
  * The resulting format will be determined by the file extension.
  *
  * @param string   $filename If omitted - original file will be overwritten
  * @param null|int $quality  Output image quality in percents 0-100
  * @return $this
  *
  * @throws Exception
  */
 public function saveAs($filename, $quality = null)
 {
     if (!$filename) {
         throw new Exception('Empty filename to save image');
     }
     $dir = FS::dirname($filename);
     if (is_dir($dir)) {
         $this->_save($filename, $quality);
     } else {
         throw new Exception('Target directory "' . $dir . '" not exists');
     }
     return $this;
 }
Exemplo n.º 2
0
 public function testDirname()
 {
     isSame('.', FS::dirname('image.png'));
     isSame('.', FS::dirname('image.jpg.png'));
     isSame('/file/path', FS::dirname('/file/path/image.jpg.png'));
     isSame('.', FS::dirname('image'));
     isSame('', FS::dirname(''));
     isSame('', FS::dirname(null));
     isSame('', FS::dirname(false));
 }