Ouzo\Utilities\Files::move PHP Method

move() public static method

Moves file from the source to the destination, throws FileNotFoundException if the source directory does not exist.
public static move ( string $sourcePath, string $destinationPath ) : boolean
$sourcePath string
$destinationPath string
return boolean
    public static function move($sourcePath, $destinationPath)
    {
        if (!self::exists($sourcePath)) {
            throw new FileNotFoundException('Cannot find source file: ' . $sourcePath);
        }
        return rename($sourcePath, $destinationPath);
    }

Usage Example

コード例 #1
0
ファイル: FilesTest.php プロジェクト: letsdrink/ouzo
 /**
  * @test
  */
 public function shouldMoveFile()
 {
     //given
     $filePath = Path::joinWithTemp('files_test');
     file_put_contents($filePath, 'test');
     $newPath = Path::joinWithTemp('new_files_test');
     //when
     $isMoved = Files::move($filePath, $newPath);
     //then
     $this->assertTrue($isMoved);
     $this->assertFileNotExists($filePath);
     $this->assertFileExists($newPath);
     Files::delete($newPath);
 }