public static function createFromRemote($git, $repositoryPath = null, string $binary = null, $name = null)
    {
        if (null === $repositoryPath) {
            $tempDir = realpath(sys_get_temp_dir());
            $repositoryPath = sprintf('%s%s%s', $tempDir, DIRECTORY_SEPARATOR, sha1(uniqid()));
            $fs = new Filesystem();
            $fs->mkdir($repositoryPath);
        }
        $repository = new Repository($repositoryPath, $binary, $name);
        if ($git instanceof Repository) {
            $git = $git->getPath();
        }
        $repository->cloneFrom($git, $repositoryPath);
        $repository->checkoutAllRemoteBranches();

        return $repository;
    }
public static function createFromRemote($git, $repositoryPath = null, string $binary = null, $name = null)
    {
        if (null === $repositoryPath) {
            $tempDir = realpath(sys_get_temp_dir());
            $repositoryPath = sprintf('%s%s%s', $tempDir, DIRECTORY_SEPARATOR, sha1(uniqid()));
            $fs = new Filesystem();
            $fs->mkdir($repositoryPath);
        }
        $repository = new Repository($repositoryPath, $binary, $name);
        if ($git instanceof Repository) {
            $git = $git->getPath();
        }
        $repository->cloneFrom($git, $repositoryPath);
        $repository->checkoutAllRemoteBranches();

        return $repository;
    }
public static function createFromRemote ( $ git , $ repositoryPath = null , string $ binary = null , $ name = null ) { if ( null === $ repositoryPath ) { $ tempDir = realpath ( sys_get_temp_dir ( ) ) ; $ repositoryPath = sprintf ( '%s%s%s' , $ tempDir , DIRECTORY_SEPARATOR , sha1 ( uniqid ( ) ) ) ; $ fs = new Filesystem ( ) ; $ fs -> mkdir ( $ repositoryPath ) ; } $ repository = new Repository ( $ repositoryPath , $ binary , $ name ) ; if ( $ git instanceof Repository ) { $ git = $ git -> getPath ( ) ; } $ repository -> cloneFrom ( $ git , $ repositoryPath ) ; $ repository -> checkoutAllRemoteBranches ( ) ; return $ repository ; }
create a repository from a remote git url, or a local filesystem
and save it in a temp folder

@param string|Repository $git            the git remote url, or the filesystem path
@param null              $repositoryPath path
@param string|null $binary         the path to the git binary
@param null              $name           repository name

@throws \RuntimeException
@throws \Symfony\Component\Filesystem\Exception\IOException
@return Repository
create a repository from a remote git url or a local filesystem and save it in a temp folder