private function deleteDirectoryTree($directory)
    {
        $filePaths = scandir($directory);

        foreach ($filePaths as $filePath) {
            if ($filePath == '.' || $filePath == '..') {
                continue;
            }

            $fullFilePath = $directory.'/'.$filePath;
            if (is_dir($fullFilePath)) {
                $result = $this->deleteDirectoryTree($fullFilePath);
                if ($result) {
                    $result = rmdir($fullFilePath);
                }
            } else {
                if (basename($fullFilePath) == '.keep') {
                    continue;
                }
                $result = unlink($fullFilePath);
            }

            if (!$result) {
                return false;
            }
        }

        return true;
    }
private function deleteDirectoryTree($directory)
    {
        $filePaths = scandir($directory);

        foreach ($filePaths as $filePath) {
            if ($filePath == '.' || $filePath == '..') {
                continue;
            }

            $fullFilePath = $directory.'/'.$filePath;
            if (is_dir($fullFilePath)) {
                $result = $this->deleteDirectoryTree($fullFilePath);
                if ($result) {
                    $result = rmdir($fullFilePath);
                }
            } else {
                if (basename($fullFilePath) == '.keep') {
                    continue;
                }
                $result = unlink($fullFilePath);
            }

            if (!$result) {
                return false;
            }
        }

        return true;
    }
private function deleteDirectoryTree ( $ directory ) { $ filePaths = scandir ( $ directory ) ; foreach ( $ filePaths as $ filePath ) { if ( $ filePath == '.' || $ filePath == '..' ) { continue ; } $ fullFilePath = $ directory . '/' . $ filePath ; if ( is_dir ( $ fullFilePath ) ) { $ result = $ this -> deleteDirectoryTree ( $ fullFilePath ) ; if ( $ result ) { $ result = rmdir ( $ fullFilePath ) ; } } else { if ( basename ( $ fullFilePath ) == '.keep' ) { continue ; } $ result = unlink ( $ fullFilePath ) ; } if ( ! $ result ) { return false ; } } return true ; }
Removes cache files from a given directory.

@param string $directory

@return bool
Removes cache files from a given directory .