Code Duplication    Length = 26-26 lines in 2 locations

src/functions.php 2 locations

@@ 426-451 (lines=26) @@
423
 * @param string $destination
424
 * @param array $config
425
 */
426
function upload($source, $destination, array $config = [])
427
{
428
    $rsync = Deployer::get()->rsync;
429
    $host = Context::get()->getHost();
430
    $source = parse($source);
431
    $destination = parse($destination);
432
433
    if ($host instanceof Localhost) {
434
        $rsync->call($host->getHostname(), $source, $destination, $config);
435
    } else {
436
        if (!isset($config['options']) || !is_array($config['options'])) {
437
            $config['options'] = [];
438
        }
439
440
        $sshArguments = $host->getSshArguments()->getCliArguments();
441
        if (empty($sshArguments) === false) {
442
            $config['options'][] = "-e 'ssh $sshArguments'";
443
        }
444
445
        if ($host->has("become")) {
446
            $config['options'][]  = "--rsync-path='sudo -H -u " . $host->get('become') . " rsync'";
447
        }
448
449
        $rsync->call($host->getHostname(), $source, "$host:$destination", $config);
450
    }
451
}
452
453
/**
454
 * Download file or directory from host
@@ 460-485 (lines=26) @@
457
 * @param string $source
458
 * @param array $config
459
 */
460
function download($source, $destination, array $config = [])
461
{
462
    $rsync = Deployer::get()->rsync;
463
    $host = Context::get()->getHost();
464
    $source = parse($source);
465
    $destination = parse($destination);
466
467
    if ($host instanceof Localhost) {
468
        $rsync->call($host->getHostname(), $source, $destination, $config);
469
    } else {
470
        if (!isset($config['options']) || !is_array($config['options'])) {
471
            $config['options'] = [];
472
        }
473
474
        $sshArguments = $host->getSshArguments()->getCliArguments();
475
        if (empty($sshArguments) === false) {
476
            $config['options'][] = "-e 'ssh $sshArguments'";
477
        }
478
479
        if ($host->has("become")) {
480
            $config['options'][]  = "--rsync-path='sudo -H -u " . $host->get('become') . " rsync'";
481
        }
482
483
        $rsync->call($host->getHostname(), "$host:$source", $destination, $config);
484
    }
485
}
486
487
/**
488
 * Writes a message to the output and adds a newline at the end.