private function deleteCacheSubfolderRecursively($dir)
    {
        if (is_dir($dir)) {
            $objects = scandir($dir);
            foreach ($objects as $object) {
                if ($dir . DIRECTORY_SEPARATOR . $object == $this->cache_path) {
                    return false;
                } elseif ($object != '.' && $object != '..') {
                    if (is_writable($dir . DIRECTORY_SEPARATOR . $object)) {
                        if (is_dir($dir . DIRECTORY_SEPARATOR . $object)) {
                            $this->deleteCacheSubfolderRecursively($dir . DIRECTORY_SEPARATOR . $object);
                        } else {
                            unlink($dir . DIRECTORY_SEPARATOR . $object);
                        }
                    } else {
                        return false;
                    }
                }
            }

            if ($dir !== $this->cache_path) {
                rmdir($dir);
            }
        }
    }
private function deleteCacheSubfolderRecursively($dir)
    {
        if (is_dir($dir)) {
            $objects = scandir($dir);
            foreach ($objects as $object) {
                if ($dir . DIRECTORY_SEPARATOR . $object == $this->cache_path) {
                    return false;
                } elseif ($object != '.' && $object != '..') {
                    if (is_writable($dir . DIRECTORY_SEPARATOR . $object)) {
                        if (is_dir($dir . DIRECTORY_SEPARATOR . $object)) {
                            $this->deleteCacheSubfolderRecursively($dir . DIRECTORY_SEPARATOR . $object);
                        } else {
                            unlink($dir . DIRECTORY_SEPARATOR . $object);
                        }
                    } else {
                        return false;
                    }
                }
            }

            if ($dir !== $this->cache_path) {
                rmdir($dir);
            }
        }
    }
private function deleteCacheSubfolderRecursively ( $ dir ) { if ( is_dir ( $ dir ) ) { $ objects = scandir ( $ dir ) ; foreach ( $ objects as $ object ) { if ( $ dir . DIRECTORY_SEPARATOR . $ object == $ this -> cache_path ) { return false ; } elseif ( $ object != '.' && $ object != '..' ) { if ( is_writable ( $ dir . DIRECTORY_SEPARATOR . $ object ) ) { if ( is_dir ( $ dir . DIRECTORY_SEPARATOR . $ object ) ) { $ this -> deleteCacheSubfolderRecursively ( $ dir . DIRECTORY_SEPARATOR . $ object ) ; } else { unlink ( $ dir . DIRECTORY_SEPARATOR . $ object ) ; } } else { return false ; } } } if ( $ dir !== $ this -> cache_path ) { rmdir ( $ dir ) ; } } }
Delete cache files and all sub folders recursively.

@param string $dir Path to main cache folder.
@return boolean Return false on something error.
Delete cache files and all sub folders recursively .