Code Duplication    Length = 20-20 lines in 2 locations

src/functions.php 2 locations

@@ 421-440 (lines=20) @@
418
 * @param string $destination
419
 * @param array $config
420
 */
421
function upload($source, $destination, array $config = [])
422
{
423
    $rsync = Deployer::get()->rsync;
424
    $host = Context::get()->getHost();
425
    $source = parse($source);
426
    $destination = parse($destination);
427
428
    if ($host instanceof Localhost) {
429
        $rsync->call($host->getHostname(), $source, $destination, $config);
430
    } else {
431
        $sshArguments = $host->getSshArguments()->getCliArguments();
432
        if (empty($sshArguments) === false) {
433
            if (!isset($config['options']) || !is_array($config['options'])) {
434
                $config['options'] = [];
435
            }
436
            $config['options'][] = "-e 'ssh $sshArguments'";
437
        }
438
        $rsync->call($host->getHostname(), $source, "$host:$destination", $config);
439
    }
440
}
441
442
/**
443
 * Download file or directory from host
@@ 449-468 (lines=20) @@
446
 * @param string $source
447
 * @param array $config
448
 */
449
function download($source, $destination, array $config = [])
450
{
451
    $rsync = Deployer::get()->rsync;
452
    $host = Context::get()->getHost();
453
    $source = parse($source);
454
    $destination = parse($destination);
455
456
    if ($host instanceof Localhost) {
457
        $rsync->call($host->getHostname(), $source, $destination, $config);
458
    } else {
459
        $sshArguments = $host->getSshArguments()->getCliArguments();
460
        if (empty($sshArguments) === false) {
461
            if (!isset($config['options']) || !is_array($config['options'])) {
462
                $config['options'] = [];
463
            }
464
            $config['options'][] = "-e 'ssh $sshArguments'";
465
        }
466
        $rsync->call($host->getHostname(), "$host:$source", $destination, $config);
467
    }
468
}
469
470
/**
471
 * Writes a message to the output and adds a newline at the end.