public function delete($clean_only = false): bool
    {
        $path = $this->replaceDirectorySeperator($this->filename);

        if (!file_exists($path)) {
            return true;
        }

        if (!is_dir($path)) {
            return unlink($path);
        }

        $files = scandir($path);

        foreach ($files as $item) {

            $file = $path . DIRECTORY_SEPARATOR . $item;

            if (is_dir($file)) {
                $this->delete($file);
            }
            else {
                unlink($file);
            }
        }

        return $clean_only == false ? rmdir($path) : true;
    }
public function delete($clean_only = false): bool
    {
        $path = $this->replaceDirectorySeperator($this->filename);

        if (!file_exists($path)) {
            return true;
        }

        if (!is_dir($path)) {
            return unlink($path);
        }

        $files = scandir($path);

        foreach ($files as $item) {

            $file = $path . DIRECTORY_SEPARATOR . $item;

            if (is_dir($file)) {
                $this->delete($file);
            }
            else {
                unlink($file);
            }
        }

        return $clean_only == false ? rmdir($path) : true;
    }
public function delete ( $ clean_only = false ) : bool { $ path = $ this -> replaceDirectorySeperator ( $ this -> filename ) ; if ( ! file_exists ( $ path ) ) { return true ; } if ( ! is_dir ( $ path ) ) { return unlink ( $ path ) ; } $ files = scandir ( $ path ) ; foreach ( $ files as $ item ) { $ file = $ path . DIRECTORY_SEPARATOR . $ item ; if ( is_dir ( $ file ) ) { $ this -> delete ( $ file ) ; } else { unlink ( $ file ) ; } } return $ clean_only == false ? rmdir ( $ path ) : true ; }
Deletes a file or a complete directory tree

@param boolean $clean_only
Flag to delete only files while a directorystructure stays intact

@return bool
Deletes a file or a complete directory tree