original_string: public function copyFolder($originalPath, $newPath)
      {
          $disk = $this->getStorageDisk();
  
          $copyDirectory = function ($srcPath, $destPath) use (&$copyDirectory, $disk) {
              $srcPath = self::validatePath($srcPath);
              $fullSrcPath = $this->getMediaPath($srcPath);
  
              $destPath = self::validatePath($destPath);
              $fullDestPath = $this->getMediaPath($destPath);
  
              if (!$disk->makeDirectory($fullDestPath)) {
                  return false;
              }
  
              $folderContents = $this->scanFolderContents($fullSrcPath);
  
              foreach ($folderContents['folders'] as $dirInfo) {
                  if (!$copyDirectory($dirInfo->path, $destPath.'/'.basename($dirInfo->path))) {
                      return false;
                  }
              }
  
              foreach ($folderContents['files'] as $fileInfo) {
                  $fullFileSrcPath = $this->getMediaPath($fileInfo->path);
  
                  if (!$disk->copy($fullFileSrcPath, $fullDestPath.'/'.basename($fileInfo->path))) {
                      return false;
                  }
              }
  
              return true;
          };
  
          return $copyDirectory($originalPath, $newPath);
      }
code: public function copyFolder($originalPath, $newPath)
      {
          $disk = $this->getStorageDisk();
  
          $copyDirectory = function ($srcPath, $destPath) use (&$copyDirectory, $disk) {
              $srcPath = self::validatePath($srcPath);
              $fullSrcPath = $this->getMediaPath($srcPath);
  
              $destPath = self::validatePath($destPath);
              $fullDestPath = $this->getMediaPath($destPath);
  
              if (!$disk->makeDirectory($fullDestPath)) {
                  return false;
              }
  
              $folderContents = $this->scanFolderContents($fullSrcPath);
  
              foreach ($folderContents['folders'] as $dirInfo) {
                  if (!$copyDirectory($dirInfo->path, $destPath.'/'.basename($dirInfo->path))) {
                      return false;
                  }
              }
  
              foreach ($folderContents['files'] as $fileInfo) {
                  $fullFileSrcPath = $this->getMediaPath($fileInfo->path);
  
                  if (!$disk->copy($fullFileSrcPath, $fullDestPath.'/'.basename($fileInfo->path))) {
                      return false;
                  }
              }
  
              return true;
          };
  
          return $copyDirectory($originalPath, $newPath);
      }
code_tokens: public function copyFolder ( $ originalPath , $ newPath ) { $ disk = $ this -> getStorageDisk ( ) ; $ copyDirectory = function ( $ srcPath , $ destPath ) use ( & $ copyDirectory , $ disk ) { $ srcPath = self :: validatePath ( $ srcPath ) ; $ fullSrcPath = $ this -> getMediaPath ( $ srcPath ) ; $ destPath = self :: validatePath ( $ destPath ) ; $ fullDestPath = $ this -> getMediaPath ( $ destPath ) ; if ( ! $ disk -> makeDirectory ( $ fullDestPath ) ) { return false ; } $ folderContents = $ this -> scanFolderContents ( $ fullSrcPath ) ; foreach ( $ folderContents [ 'folders' ] as $ dirInfo ) { if ( ! $ copyDirectory ( $ dirInfo -> path , $ destPath . '/' . basename ( $ dirInfo -> path ) ) ) { return false ; } } foreach ( $ folderContents [ 'files' ] as $ fileInfo ) { $ fullFileSrcPath = $ this -> getMediaPath ( $ fileInfo -> path ) ; if ( ! $ disk -> copy ( $ fullFileSrcPath , $ fullDestPath . '/' . basename ( $ fileInfo -> path ) ) ) { return false ; } } return true ; } ; return $ copyDirectory ( $ originalPath , $ newPath ) ; }
docstring: Copies a folder.
  @param string $originalPath Specifies the original path of the folder.
  @param string $newPath Specifies the new path of the folder.
  @return boolean
docstring_tokens: Copies a folder .