public function create($name, $description = "new repo", $password = ''): bool
    {
        // only create a library which is not empty to prevent wrong implementation
        if (empty($name)) {
            return false;
        }

        // Do not create libraries that already exist
        if ($this->exists($name)) {
            return false;
        }

        $uri = sprintf(
            '%s/repos/',
            $this->clipUri($this->client->getConfig('base_uri'))
        );

        $multipartData = [
            [
                'name'     => 'name',
                'contents' => $name,
            ],
            [
                'name'     => 'desc',
                'contents' => $description,
            ],
        ];

        if ($password !== '') {
            $multipartData[] = [
                'name'     => 'passwd',
                'contents' => $password,
            ];
        }

        $response = $this->client->request(
            'POST',
            $uri,
            [
                'headers'   => ['Accept' => 'application/json'],
                'multipart' => $multipartData,
            ]
        );

        return $response->getStatusCode() === 200;
    }
public function create($name, $description = "new repo", $password = ''): bool
    {
        // only create a library which is not empty to prevent wrong implementation
        if (empty($name)) {
            return false;
        }

        // Do not create libraries that already exist
        if ($this->exists($name)) {
            return false;
        }

        $uri = sprintf(
            '%s/repos/',
            $this->clipUri($this->client->getConfig('base_uri'))
        );

        $multipartData = [
            [
                'name'     => 'name',
                'contents' => $name,
            ],
            [
                'name'     => 'desc',
                'contents' => $description,
            ],
        ];

        if ($password !== '') {
            $multipartData[] = [
                'name'     => 'passwd',
                'contents' => $password,
            ];
        }

        $response = $this->client->request(
            'POST',
            $uri,
            [
                'headers'   => ['Accept' => 'application/json'],
                'multipart' => $multipartData,
            ]
        );

        return $response->getStatusCode() === 200;
    }
public function create ( $ name , $ description = "new repo" , $ password = '' ) : bool { // only create a library which is not empty to prevent wrong implementation if ( empty ( $ name ) ) { return false ; } // Do not create libraries that already exist if ( $ this -> exists ( $ name ) ) { return false ; } $ uri = sprintf ( '%s/repos/' , $ this -> clipUri ( $ this -> client -> getConfig ( 'base_uri' ) ) ) ; $ multipartData = [ [ 'name' => 'name' , 'contents' => $ name , ] , [ 'name' => 'desc' , 'contents' => $ description , ] , ] ; if ( $ password !== '' ) { $ multipartData [ ] = [ 'name' => 'passwd' , 'contents' => $ password , ] ; } $ response = $ this -> client -> request ( 'POST' , $ uri , [ 'headers' => [ 'Accept' => 'application/json' ] , 'multipart' => $ multipartData , ] ) ; return $ response -> getStatusCode ( ) === 200 ; }
Create a new library

@param string $name        Library name
@param string $description Library description
@param string $password    false means no encryption, any other string is used as password

@return bool
@throws \Exception
@throws \GuzzleHttp\Exception\GuzzleException
Create a new library