original_string: protected function clearDir($dir)
      {
          $iterator = new \DirectoryIterator($dir);
          foreach ($iterator as $file) {
  
              if ($file->isDir() && !$file->isDot() && !preg_match("~\.~", $file)) {
                  $this->clearDir($file->getPathname());
                  if (!\rmdir($file->getPathname())) {
                      return false;
                  }
              } elseif ($file->isFile()) {
                  if (!\unlink($file->getPathname())) {
                      return false;
                  }
              }
          }
  
          return true;
      }
code: protected function clearDir($dir)
      {
          $iterator = new \DirectoryIterator($dir);
          foreach ($iterator as $file) {
  
              if ($file->isDir() && !$file->isDot() && !preg_match("~\.~", $file)) {
                  $this->clearDir($file->getPathname());
                  if (!\rmdir($file->getPathname())) {
                      return false;
                  }
              } elseif ($file->isFile()) {
                  if (!\unlink($file->getPathname())) {
                      return false;
                  }
              }
          }
  
          return true;
      }
code_tokens: protected function clearDir ( $ dir ) { $ iterator = new \ DirectoryIterator ( $ dir ) ; foreach ( $ iterator as $ file ) { if ( $ file -> isDir ( ) && ! $ file -> isDot ( ) && ! preg_match ( "~\.~" , $ file ) ) { $ this -> clearDir ( $ file -> getPathname ( ) ) ; if ( ! \ rmdir ( $ file -> getPathname ( ) ) ) { return false ; } } elseif ( $ file -> isFile ( ) ) { if ( ! \ unlink ( $ file -> getPathname ( ) ) ) { return false ; } } } return true ; }
docstring: Clears out the contents of a cache directory
  @param $dir
  @return boolean
docstring_tokens: Clears out the contents of a cache directory