Gush\ThirdParty\Bitbucket\BitbucketRepoAdapter::createFork PHP Метод

createFork() публичный Метод

public createFork ( $org )
    public function createFork($org)
    {
        $response = $this->client->apiRepository()->get($this->getUsername(), $this->getRepository());
        $resultArray = json_decode($response->getContent(), true);
        if ('no_forks' === $resultArray['fork_policy']) {
            throw new AdapterException('Forking is not allowed for this repository.');
        }
        if ('git' !== $resultArray['scm']) {
            throw new AdapterException('Repository type is not git, only git is supported.');
        }
        if ($this->getUsername() === $resultArray['owner']['username']) {
            // BitBucket always forks to the current user account, so prefix it
            // with the org to make it unique
            $name = $org . '-' . $resultArray['name'];
        } else {
            $name = $resultArray['name'];
        }
        $response = $this->client->apiRepository()->fork($this->getUsername(), $this->getRepository(), $name, ['is_private' => $response]);
        $resultArray = json_decode($response->getContent(), true);
        return ['git_url' => '[email protected]:' . $resultArray['owner'] . '/' . $resultArray['slug'] . '.git', 'html_url' => $this->domain . '/' . $resultArray['owner'] . '/' . $resultArray['slug']];
    }