private function cloneByPackageName($args)
    {
        $packageName = $args[0];
        if (!$this->existsPackageName($packageName)) {
            $args[0] = 'https://github.com/'.$packageName;

            return $this->cloneByRepositoryUrl($args);
        }

        $projectName = isset($args[1]) ? $args[1] : basename($packageName);
        if ($this->existsProjectName($projectName)) {
            return "> Producer: Project directory '{$this->projectsDir}/{$projectName}' already exists.\n";
        }

        if (!$this->existsRootComposerJson()) {
            $this->createRootComposerJson();
        }

        $devFlag = in_array($packageName, $this->devPackages) ? '--dev' : '';
        $this->exec('clone', 'require-package', [$packageName, $devFlag]);

        $composerJson = $this->cwd.'/vendor/'.$packageName.'/composer.json';
        if (!file_exists($composerJson)) {
            return "> Producer: Package not found.\n";
        }

        $json = json_decode(file_get_contents($composerJson));
        $repositoryUrl = null;
        if (isset($json->repositories)) {
            foreach ($json->repositories as $item) {
                if ($item->type == 'git') {
                    $repositoryUrl = $item->url;
                    break;
                }
            }
        }

        if (!$repositoryUrl) {
            return "> Producer: Repository not found on composer.json.\n";
        }

        if (!$this->existsRepositoryUrl($repositoryUrl)) {
            return 'Repository url not exists!';
        }

        return $this->exec('clone', 'clone', [$repositoryUrl, $packageName, $projectName]);
    }
private function cloneByPackageName($args)
    {
        $packageName = $args[0];
        if (!$this->existsPackageName($packageName)) {
            $args[0] = 'https://github.com/'.$packageName;

            return $this->cloneByRepositoryUrl($args);
        }

        $projectName = isset($args[1]) ? $args[1] : basename($packageName);
        if ($this->existsProjectName($projectName)) {
            return "> Producer: Project directory '{$this->projectsDir}/{$projectName}' already exists.\n";
        }

        if (!$this->existsRootComposerJson()) {
            $this->createRootComposerJson();
        }

        $devFlag = in_array($packageName, $this->devPackages) ? '--dev' : '';
        $this->exec('clone', 'require-package', [$packageName, $devFlag]);

        $composerJson = $this->cwd.'/vendor/'.$packageName.'/composer.json';
        if (!file_exists($composerJson)) {
            return "> Producer: Package not found.\n";
        }

        $json = json_decode(file_get_contents($composerJson));
        $repositoryUrl = null;
        if (isset($json->repositories)) {
            foreach ($json->repositories as $item) {
                if ($item->type == 'git') {
                    $repositoryUrl = $item->url;
                    break;
                }
            }
        }

        if (!$repositoryUrl) {
            return "> Producer: Repository not found on composer.json.\n";
        }

        if (!$this->existsRepositoryUrl($repositoryUrl)) {
            return 'Repository url not exists!';
        }

        return $this->exec('clone', 'clone', [$repositoryUrl, $packageName, $projectName]);
    }
private function cloneByPackageName ( $ args ) { $ packageName = $ args [ 0 ] ; if ( ! $ this -> existsPackageName ( $ packageName ) ) { $ args [ 0 ] = 'https://github.com/' . $ packageName ; return $ this -> cloneByRepositoryUrl ( $ args ) ; } $ projectName = isset ( $ args [ 1 ] ) ? $ args [ 1 ] : basename ( $ packageName ) ; if ( $ this -> existsProjectName ( $ projectName ) ) { return "> Producer: Project directory '{$this->projectsDir}/{$projectName}' already exists.\n" ; } if ( ! $ this -> existsRootComposerJson ( ) ) { $ this -> createRootComposerJson ( ) ; } $ devFlag = in_array ( $ packageName , $ this -> devPackages ) ? '--dev' : '' ; $ this -> exec ( 'clone' , 'require-package' , [ $ packageName , $ devFlag ] ) ; $ composerJson = $ this -> cwd . '/vendor/' . $ packageName . '/composer.json' ; if ( ! file_exists ( $ composerJson ) ) { return "> Producer: Package not found.\n" ; } $ json = json_decode ( file_get_contents ( $ composerJson ) ) ; $ repositoryUrl = null ; if ( isset ( $ json -> repositories ) ) { foreach ( $ json -> repositories as $ item ) { if ( $ item -> type == 'git' ) { $ repositoryUrl = $ item -> url ; break ; } } } if ( ! $ repositoryUrl ) { return "> Producer: Repository not found on composer.json.\n" ; } if ( ! $ this -> existsRepositoryUrl ( $ repositoryUrl ) ) { return 'Repository url not exists!' ; } return $ this -> exec ( 'clone' , 'clone' , [ $ repositoryUrl , $ packageName , $ projectName ] ) ; }
Clone repository by package name.

@param mixed $args
Clone repository by package name .