/**
* Clean cache for a group given a mode.
*
* group mode : cleans all cache in the group
* notgroup mode : cleans all cache not in the group
*
* @param string $group The cache data group
* @param string $mode The mode for cleaning cache [group|notgroup]
*
* @return boolean
*
* @since 1.7.0
*/
public function clean($group, $mode = null)
{
$return = true;
$folder = $group;
if (trim($folder) == '') {
$mode = 'notgroup';
}
switch ($mode) {
case 'notgroup':
$folders = $this->_folders($this->_root);
for ($i = 0, $n = \count($folders); $i < $n; $i++) {
if ($folders[$i] != $folder) {
$return |= $this->_deleteFolder($this->_root . '/' . $folders[$i]);
}
}
break;
case 'group':
default:
if (is_dir($this->_root . '/' . $folder)) {
$return = $this->_deleteFolder($this->_root . '/' . $folder);
}
break;
}
return (bool) $return;
}