keys() as $key) { if (!$adapter->isDirectory($key)) { $adapter->delete($key); } } $keys = $adapter->keys(); rsort($keys); foreach ($keys as $key) { $adapter->delete($key); } return $adapter;