Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/sebastianfeldmann/git/src/Repository/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/sebastianfeldmann/git/src/Repository/Cloner.php
<?php

/**
 * This file is part of SebastianFeldmann\Git.
 *
 * (c) Sebastian Feldmann <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

namespace SebastianFeldmann\Git\Repository;

use SebastianFeldmann\Cli\Command\Runner;
use SebastianFeldmann\Git\Command\CloneCmd\CloneCmd;
use SebastianFeldmann\Git\Repository;
use SebastianFeldmann\Git\Url;

/**
 * Class Cloner
 *
 * Responsible for all `git clone` operations
 *
 * @package SebastianFeldmann\Git
 * @author  Andreas Frömer
 * @author  Sebastian Feldmann <[email protected]>
 * @link    https://github.com/sebastianfeldmann/git
 * @since   Class available since Release 3.8.0
 */
final class Cloner
{
    /**
     * @var string
     */
    private $root;

    /**
     * @var int
     */
    private $depth = 0;

    /**
     * @var \SebastianFeldmann\Cli\Command\Runner
     */
    private $runner;

    /**
     * Cloner constructor
     *
     * @param string $root
     * @param Runner|null $runner
     */
    public function __construct(string $root = '', Runner $runner = null)
    {
        $this->root   = empty($root) ? (string) getcwd() : $root;
        $this->runner = $runner ?? new Runner\Simple();
    }

    /**
     * Set the `--depth` option
     *
     * @param  int $depth
     * @return $this
     */
    public function depth(int $depth): Cloner
    {
        $this->depth = $depth;
        return $this;
    }

    /**
     * Clone a given repository $url.
     *
     * @param string $url Url of repository
     * @param string $dir The directory where the content should be cloned into.
     *                    If this is an absolute path this directory will be used.
     *                    If this is a relative path, and new folder will be created inside
     *                    the current working directory.
     */
    public function clone(string $url, string $dir = ''): Repository
    {
        $repositoryUrl = new Url($url);
        $cloneCommand  = new CloneCmd($repositoryUrl);

        if (empty($dir)) {
            $dir = $this->root . '/' . $repositoryUrl->getRepoName();
        }

        $cloneCommand->dir($dir);

        if ($this->depth > 0) {
            $cloneCommand->depth($this->depth);
        }

        $this->runner->run($cloneCommand);

        return Repository::createVerified($dir, $this->runner);
    }
}

Spamworldpro Mini