Update #1

Merged
Llewellyn merged 4 commits from dev into master 2023-08-01 07:43:29 +00:00
7 changed files with 39 additions and 18 deletions

View File

@ -830,7 +830,6 @@ class Repository implements ServiceProviderInterface
$container->get('Gitea.Dynamic.Uri'),
$container->get('Gitea.Utilities.Response')
);
}
}
}

View File

@ -767,4 +767,4 @@
$container->get('Gitea.Dynamic.Uri'),
$container->get('Gitea.Utilities.Response')
);
}
}

View File

@ -44,7 +44,7 @@ final class Response
// Decode the error response and throw an exception.
$message = $this->error($response);
throw new \DomainException("Invalid response received from API.$message", $response->code);
throw new \DomainException("Invalid response received from API. $message", $response->code);
}
@ -70,7 +70,7 @@ final class Response
// Decode the error response and throw an exception.
$message = $this->error($response);
throw new \DomainException("Invalid response received from API.$message", $response->code);
throw new \DomainException("Invalid response received from API. $message", $response->code);
}
@ -134,6 +134,10 @@ final class Response
{
return $error->error;
}
elseif (isset($error->message))
{
return $error->message;
}
return '';
}

View File

@ -18,7 +18,7 @@
// Decode the error response and throw an exception.
$message = $this->error($response);
throw new \DomainException("Invalid response received from API.$message", $response->code);
throw new \DomainException("Invalid response received from API. $message", $response->code);
}
@ -44,7 +44,7 @@
// Decode the error response and throw an exception.
$message = $this->error($response);
throw new \DomainException("Invalid response received from API.$message", $response->code);
throw new \DomainException("Invalid response received from API. $message", $response->code);
}
@ -108,6 +108,10 @@
{
return $error->error;
}
elseif (isset($error->message))
{
return $error->message;
}
return '';
}

View File

@ -15,7 +15,7 @@ abstract Api #Orange {
# Uri $uri
# Response $response
+ __construct(Http $http, Uri $uri, ...)
+ load_(string $url, string $token) : void
+ load_(?string $url = null, ?string $token = null) : void
}
note right of Api::__construct

View File

@ -67,16 +67,23 @@ abstract class Api
/**
* Load/Reload API.
*
* @param string $url The url.
* @param token $token The token.
* @param string|null $url The url.
* @param token|null $token The token.
*
* @return void
* @since 3.2.0
**/
public function load_(string $url, string $token)
public function load_(?string $url = null, ?string $token = null)
{
$this->uri->setUrl($url);
$this->http->setToken($token);
if ($url !== null)
{
$this->uri->setUrl($url);
}
if ($token !== null)
{
$this->http->setToken($token);
}
}
}

View File

@ -41,14 +41,21 @@
/**
* Load/Reload API.
*
* @param string $url The url.
* @param token $token The token.
* @param string|null $url The url.
* @param token|null $token The token.
*
* @return void
* @since 3.2.0
**/
public function load_(string $url, string $token)
public function load_(?string $url = null, ?string $token = null)
{
$this->uri->setUrl($url);
$this->http->setToken($token);
if ($url !== null)
{
$this->uri->setUrl($url);
}
if ($token !== null)
{
$this->http->setToken($token);
}
}