Ouzo\Utilities\Files::deleteIfExists PHP Method

deleteIfExists() public static method

Deletes file if exists, otherwise return false if the file does not exist.
public static deleteIfExists ( $path ) : boolean
$path
return boolean
    public static function deleteIfExists($path)
    {
        if (self::exists($path)) {
            return self::delete($path);
        }
        return false;
    }

Usage Example

Example #1
0
 /**
  * @test
  */
 public function shouldReturnFalseIfNotExistsAnTryToDelete()
 {
     //when
     $deleteIfExists = Files::deleteIfExists('/broken/path/file');
     //then
     $this->assertFalse($deleteIfExists);
 }