original_string: public static function folderToZip($folder, &$zipFile, $exclusiveLength, $exclude = array('.git'), $prefix = '') {
  	if (!file_exists($folder)) return;
      $handle = opendir($folder);
      while (false !== $f = readdir($handle)) {
        if ($f != '.' && $f != '..') {
  		  
  		if (in_array($f, $exclude)) continue;
  		  
          $filePath = "$folder/$f";
          // Remove prefix from file path before add to zip.
          $localPath = $prefix.substr($filePath, $exclusiveLength);
          if (is_file($filePath)) {
            $zipFile->addFile($filePath, $localPath);
          } elseif (is_dir($filePath)) {
            // Add sub-directory.
            $zipFile->addEmptyDir($localPath);
            self::folderToZip($filePath, $zipFile, $exclusiveLength, $exclude, $prefix);
          }
        }
      }
      closedir($handle);
    }
code: public static function folderToZip($folder, &$zipFile, $exclusiveLength, $exclude = array('.git'), $prefix = '') {
  	if (!file_exists($folder)) return;
      $handle = opendir($folder);
      while (false !== $f = readdir($handle)) {
        if ($f != '.' && $f != '..') {
  		  
  		if (in_array($f, $exclude)) continue;
  		  
          $filePath = "$folder/$f";
          // Remove prefix from file path before add to zip.
          $localPath = $prefix.substr($filePath, $exclusiveLength);
          if (is_file($filePath)) {
            $zipFile->addFile($filePath, $localPath);
          } elseif (is_dir($filePath)) {
            // Add sub-directory.
            $zipFile->addEmptyDir($localPath);
            self::folderToZip($filePath, $zipFile, $exclusiveLength, $exclude, $prefix);
          }
        }
      }
      closedir($handle);
    }
code_tokens: public static function folderToZip ( $ folder , & $ zipFile , $ exclusiveLength , $ exclude = array ( '.git' ) , $ prefix = '' ) { if ( ! file_exists ( $ folder ) ) return ; $ handle = opendir ( $ folder ) ; while ( false !== $ f = readdir ( $ handle ) ) { if ( $ f != '.' && $ f != '..' ) { if ( in_array ( $ f , $ exclude ) ) continue ; $ filePath = "$folder/$f" ; // Remove prefix from file path before add to zip. $ localPath = $ prefix . substr ( $ filePath , $ exclusiveLength ) ; if ( is_file ( $ filePath ) ) { $ zipFile -> addFile ( $ filePath , $ localPath ) ; } elseif ( is_dir ( $ filePath ) ) { // Add sub-directory. $ zipFile -> addEmptyDir ( $ localPath ) ; self :: folderToZip ( $ filePath , $ zipFile , $ exclusiveLength , $ exclude , $ prefix ) ; } } } closedir ( $ handle ) ; }
docstring: Add files and sub-directories in a folder to zip file.
  
  @param string $folder
  @param \ZipArchive $zipFile
  @param int $exclusiveLength Number of text to be exclusived from the file path.
docstring_tokens: Add files and sub - directories in a folder to zip file .