original_string: public function delete($path = null)
      {
          if (!$path) {
              $path = $this->pwd();
          }
          if (!$path) {
              return false;
          }
          $path = Folder::slashTerm($path);
          if (is_dir($path)) {
              try {
                  $directory = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::CURRENT_AS_SELF);
                  $iterator = new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::CHILD_FIRST);
              } catch (Exception $e) {
                  return false;
              }
  
              foreach ($iterator as $item) {
                  $filePath = $item->getPathname();
                  if ($item->isFile() || $item->isLink()) {
                      //@codingStandardsIgnoreStart
                      if (@unlink($filePath)) {
                          //@codingStandardsIgnoreEnd
                          $this->_messages[] = sprintf('%s removed', $filePath);
                      } else {
                          $this->_errors[] = sprintf('%s NOT removed', $filePath);
                      }
                  } elseif ($item->isDir() && !$item->isDot()) {
                      //@codingStandardsIgnoreStart
                      if (@rmdir($filePath)) {
                          //@codingStandardsIgnoreEnd
                          $this->_messages[] = sprintf('%s removed', $filePath);
                      } else {
                          $this->_errors[] = sprintf('%s NOT removed', $filePath);
  
                          return false;
                      }
                  }
              }
  
              $path = rtrim($path, DIRECTORY_SEPARATOR);
              //@codingStandardsIgnoreStart
              if (@rmdir($path)) {
                  //@codingStandardsIgnoreEnd
                  $this->_messages[] = sprintf('%s removed', $path);
              } else {
                  $this->_errors[] = sprintf('%s NOT removed', $path);
  
                  return false;
              }
          }
  
          return true;
      }
code: public function delete($path = null)
      {
          if (!$path) {
              $path = $this->pwd();
          }
          if (!$path) {
              return false;
          }
          $path = Folder::slashTerm($path);
          if (is_dir($path)) {
              try {
                  $directory = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::CURRENT_AS_SELF);
                  $iterator = new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::CHILD_FIRST);
              } catch (Exception $e) {
                  return false;
              }
  
              foreach ($iterator as $item) {
                  $filePath = $item->getPathname();
                  if ($item->isFile() || $item->isLink()) {
                      //@codingStandardsIgnoreStart
                      if (@unlink($filePath)) {
                          //@codingStandardsIgnoreEnd
                          $this->_messages[] = sprintf('%s removed', $filePath);
                      } else {
                          $this->_errors[] = sprintf('%s NOT removed', $filePath);
                      }
                  } elseif ($item->isDir() && !$item->isDot()) {
                      //@codingStandardsIgnoreStart
                      if (@rmdir($filePath)) {
                          //@codingStandardsIgnoreEnd
                          $this->_messages[] = sprintf('%s removed', $filePath);
                      } else {
                          $this->_errors[] = sprintf('%s NOT removed', $filePath);
  
                          return false;
                      }
                  }
              }
  
              $path = rtrim($path, DIRECTORY_SEPARATOR);
              //@codingStandardsIgnoreStart
              if (@rmdir($path)) {
                  //@codingStandardsIgnoreEnd
                  $this->_messages[] = sprintf('%s removed', $path);
              } else {
                  $this->_errors[] = sprintf('%s NOT removed', $path);
  
                  return false;
              }
          }
  
          return true;
      }
code_tokens: public function delete ( $ path = null ) { if ( ! $ path ) { $ path = $ this -> pwd ( ) ; } if ( ! $ path ) { return false ; } $ path = Folder :: slashTerm ( $ path ) ; if ( is_dir ( $ path ) ) { try { $ directory = new RecursiveDirectoryIterator ( $ path , RecursiveDirectoryIterator :: CURRENT_AS_SELF ) ; $ iterator = new RecursiveIteratorIterator ( $ directory , RecursiveIteratorIterator :: CHILD_FIRST ) ; } catch ( Exception $ e ) { return false ; } foreach ( $ iterator as $ item ) { $ filePath = $ item -> getPathname ( ) ; if ( $ item -> isFile ( ) || $ item -> isLink ( ) ) { //@codingStandardsIgnoreStart if ( @ unlink ( $ filePath ) ) { //@codingStandardsIgnoreEnd $ this -> _messages [ ] = sprintf ( '%s removed' , $ filePath ) ; } else { $ this -> _errors [ ] = sprintf ( '%s NOT removed' , $ filePath ) ; } } elseif ( $ item -> isDir ( ) && ! $ item -> isDot ( ) ) { //@codingStandardsIgnoreStart if ( @ rmdir ( $ filePath ) ) { //@codingStandardsIgnoreEnd $ this -> _messages [ ] = sprintf ( '%s removed' , $ filePath ) ; } else { $ this -> _errors [ ] = sprintf ( '%s NOT removed' , $ filePath ) ; return false ; } } } $ path = rtrim ( $ path , DIRECTORY_SEPARATOR ) ; //@codingStandardsIgnoreStart if ( @ rmdir ( $ path ) ) { //@codingStandardsIgnoreEnd $ this -> _messages [ ] = sprintf ( '%s removed' , $ path ) ; } else { $ this -> _errors [ ] = sprintf ( '%s NOT removed' , $ path ) ; return false ; } } return true ; }
docstring: Recursively Remove directories if the system allows.
  
  @param string|null $path Path of directory to delete
  @return bool Success
docstring_tokens: Recursively Remove directories if the system allows .