public function run(array $sources, array $destinations)
    {
        $fileSystem = new Filesystem();
        
        // must have the same sources and destinations number
        if (count($sources) !== count($destinations) && count($destinations) !== 1) {
            throw new Exception('Sources and destinations count mismatch');
        }
        
        // if only one destination is specified for multiple sources, it should be a directory. We should create it if
        // it is not exists
        if (count($destinations) === 1 && !is_dir($destinations[0]) && count($sources) > 1) {
            $fileSystem->mkdir($destinations[0]);
        }
        $copiedFiles = [];
        
        // copy generated files to its destination
        foreach ($sources as $index => $source) {
            
            if (array_key_exists($index, $destinations)) {
                $destination = $destinations[$index];
            } else {
                $destination = $destinations[0];
            }
            
            if (is_dir($destination)) {
                $destination = $this->removeLastSlash($destination);
                
                if ($source instanceof \Symfony\Component\Finder\SplFileInfo && $source->getRelativePath()) {
                    $destination .= '/'.$source->getRelativePath();
                }
                $destination .= '/'.$source->getFilename();
            }
            $this->addNotification('copying "'.$source.'" to "'.$destination.'"');
            
            $fileSystem->copy($source->getRealPath(), $destination);
            $copiedFiles[] = $destination;
        }
        
        return $copiedFiles;
    }
public function run(array $sources, array $destinations)
    {
        $fileSystem = new Filesystem();
        
        // must have the same sources and destinations number
        if (count($sources) !== count($destinations) && count($destinations) !== 1) {
            throw new Exception('Sources and destinations count mismatch');
        }
        
        // if only one destination is specified for multiple sources, it should be a directory. We should create it if
        // it is not exists
        if (count($destinations) === 1 && !is_dir($destinations[0]) && count($sources) > 1) {
            $fileSystem->mkdir($destinations[0]);
        }
        $copiedFiles = [];
        
        // copy generated files to its destination
        foreach ($sources as $index => $source) {
            
            if (array_key_exists($index, $destinations)) {
                $destination = $destinations[$index];
            } else {
                $destination = $destinations[0];
            }
            
            if (is_dir($destination)) {
                $destination = $this->removeLastSlash($destination);
                
                if ($source instanceof \Symfony\Component\Finder\SplFileInfo && $source->getRelativePath()) {
                    $destination .= '/'.$source->getRelativePath();
                }
                $destination .= '/'.$source->getFilename();
            }
            $this->addNotification('copying "'.$source.'" to "'.$destination.'"');
            
            $fileSystem->copy($source->getRealPath(), $destination);
            $copiedFiles[] = $destination;
        }
        
        return $copiedFiles;
    }
public function run ( array $ sources , array $ destinations ) { $ fileSystem = new Filesystem ( ) ; // must have the same sources and destinations number if ( count ( $ sources ) !== count ( $ destinations ) && count ( $ destinations ) !== 1 ) { throw new Exception ( 'Sources and destinations count mismatch' ) ; } // if only one destination is specified for multiple sources, it should be a directory. We should create it if // it is not exists if ( count ( $ destinations ) === 1 && ! is_dir ( $ destinations [ 0 ] ) && count ( $ sources ) > 1 ) { $ fileSystem -> mkdir ( $ destinations [ 0 ] ) ; } $ copiedFiles = [ ] ; // copy generated files to its destination foreach ( $ sources as $ index => $ source ) { if ( array_key_exists ( $ index , $ destinations ) ) { $ destination = $ destinations [ $ index ] ; } else { $ destination = $ destinations [ 0 ] ; } if ( is_dir ( $ destination ) ) { $ destination = $ this -> removeLastSlash ( $ destination ) ; if ( $ source instanceof \ Symfony \ Component \ Finder \ SplFileInfo && $ source -> getRelativePath ( ) ) { $ destination .= '/' . $ source -> getRelativePath ( ) ; } $ destination .= '/' . $ source -> getFilename ( ) ; } $ this -> addNotification ( 'copying "' . $ source . '" to "' . $ destination . '"' ) ; $ fileSystem -> copy ( $ source -> getRealPath ( ) , $ destination ) ; $ copiedFiles [ ] = $ destination ; } return $ copiedFiles ; }
Copy the sources files to the destinations.

@param SplFileInfo[] $sources
@param string[] $destinations

@return SplFileInfo[]

@throws Exception
Copy the sources files to the destinations .