Platformsh\Cli\Helper\FilesystemHelper::remove PHP Method

remove() public method

Delete a file or directory.
public remove ( string | array | Traversable $files, boolean $retryWithChmod = false ) : boolean
$files string | array | Traversable A filename, an array of files, or a \Traversable instance to delete.
$retryWithChmod boolean Whether to retry deleting on error, after recursively changing file modes to add read/write/exec permissions. A bit like 'rm -rf'.
return boolean
    public function remove($files, $retryWithChmod = false)
    {
        try {
            $this->fs->remove($files);
        } catch (IOException $e) {
            if ($retryWithChmod && $this->unprotect($files, true)) {
                return $this->remove($files, false);
            }
            trigger_error($e->getMessage(), E_USER_WARNING);
            return false;
        }
        return true;
    }

Usage Example

 /**
  * Test FilesystemHelper::remove() on directories.
  */
 public function testRemoveDir()
 {
     // Create a test directory containing some files in several levels.
     $testDir = $this->tempDir(true);
     // Check that the directory can be removed.
     $this->assertTrue($this->filesystemHelper->remove($testDir));
     $this->assertFileNotExists($testDir);
 }
All Usage Examples Of Platformsh\Cli\Helper\FilesystemHelper::remove