Release of v5.1.1-beta1

Add JCB new package engine.
This commit is contained in:
2025-06-18 19:49:35 +00:00
parent 3b502eb09b
commit 70718936b4
464 changed files with 34151 additions and 13973 deletions

View File

@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@@ -0,0 +1,155 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Github\Abstraction;
use VDM\Joomla\Github\Utilities\Http;
use VDM\Joomla\Github\Utilities\Uri;
use VDM\Joomla\Github\Utilities\Response;
use VDM\Joomla\Interfaces\Git\ApiInterface;
/**
* The Gitea Api
*
* @since 5.1.1
*/
abstract class Api implements ApiInterface
{
/**
* The Http class
*
* @var Http
* @since 3.2.0
*/
protected Http $http;
/**
* The Uri class
*
* @var Uri
* @since 3.2.0
*/
protected Uri $uri;
/**
* The Response class
*
* @var Response
* @since 3.2.0
*/
protected Response $response;
/**
* The Url string
*
* @var string|null
* @since 3.2.0
*/
protected ?string $url = null;
/**
* The token string
*
* @var string|null
* @since 3.2.0
*/
protected ?string $token = null;
/**
* Constructor.
*
* @param Http $http The http class.
* @param Uri $uri The uri class.
* @param Response $response The response class.
*
* @since 3.2.0
**/
public function __construct(Http $http, Uri $uri, Response $response)
{
$this->http = $http;
$this->uri = $uri;
$this->response = $response;
}
/**
* Load/Reload API.
*
* @param string|null $url The url.
* @param token|null $token The token.
* @param bool $backup The backup swapping switch.
*
* @return void
* @since 3.2.0
**/
public function load_(?string $url = null, ?string $token = null, bool $backup = true): void
{
// we keep the old values
// so we can reset after our call
// for the rest of the container
if ($backup)
{
if ($url !== null)
{
$this->url = $this->uri->getUrl();
}
if ($token !== null)
{
$this->token = $this->http->getToken();
}
}
if ($url !== null)
{
$this->uri->setUrl($url);
}
if ($token !== null)
{
$this->http->setToken($token);
}
}
/**
* Reset to previous toke, url it set
*
* @return void
* @since 3.2.0
**/
public function reset_(): void
{
if ($this->url !== null)
{
$this->uri->setUrl($this->url);
$this->url = null;
}
if ($this->token !== null)
{
$this->http->setToken($this->token);
$this->token = null;
}
}
/**
* Get the API url
*
* @return string
* @since 3.2.0
**/
public function api()
{
return $this->uri->api();
}
}

View File

@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@@ -0,0 +1,482 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Github\Repository;
use VDM\Joomla\Interfaces\Git\Repository\ContentsInterface;
use VDM\Joomla\Github\Abstraction\Api;
/**
* The Github Repository Contents
*
* @since 5.1.1
*/
class Contents extends Api implements ContentsInterface
{
/**
* Get a file from a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file path.
* @param string|null $ref Optional. The name of the commit/branch/tag.
* Default the repository's default branch (usually master).
*
* @return mixed
* @since 5.1.1
**/
public function get(string $owner, string $repo, string $filepath, ?string $ref = null)
{
// Build the request path.
$path = "/repos/{$owner}/{$repo}/contents/{$filepath}";
// Get the URI with the specified path.
$uri = $this->uri->get($path);
// Add the ref parameter if provided.
if ($ref !== null)
{
$uri->setVar('ref', $ref);
}
// Send the get request.
return $this->response->get(
$this->http->raw()->get($uri)
);
}
/**
* Get the metadata and contents (if a file) of an entry in a repository,
* or a list of entries if a directory.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file or directory path.
* @param string|null $ref Optional. The name of the commit/branch/tag.
* Default the repository's default branch (usually master).
*
* @return null|array|object
* @since 5.1.1
**/
public function metadata(string $owner, string $repo, string $filepath, ?string $ref = null): null|array|object
{
// Build the request path.
$path = "/repos/{$owner}/{$repo}/contents/{$filepath}";
// Get the URI with the specified path.
$uri = $this->uri->get($path);
// Add the ref parameter if provided.
if ($ref !== null)
{
$uri->setVar('ref', $ref);
}
// Send the get request.
return $this->response->get(
$this->http->json()->get($uri)
);
}
/**
* Create a file in a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file path.
* @param string $content The file content.
* @param string $message The commit message.
* @param string $branch The branch name. Defaults to the repository's default branch.
* @param string|null $authorName The author's name.
* @param string|null $authorEmail The author's email.
* @param string|null $committerName The committer's name.
* @param string|null $committerEmail The committer's email.
* @param string|null $newBranch Whether to create a new branch. Defaults to null.
* @param string|null $authorDate The author's date.
* @param string|null $committerDate The committer's date.
* @param bool|null $signoff Add a Signed-off-by trailer. Defaults to null.
*
* @return object|null
* @since 5.1.1
**/
public function create(
string $owner,
string $repo,
string $filepath,
string $content,
string $message,
string $branch = 'master',
?string $authorName = null,
?string $authorEmail = null,
?string $committerName = null,
?string $committerEmail = null,
?string $newBranch = null,
?string $authorDate = null,
?string $committerDate = null,
?bool $signoff = null
): ?object {
// Build the request path.
$path = "/repos/{$owner}/{$repo}/contents/{$filepath}";
// Set the post data
$data = new \stdClass();
$data->content = base64_encode($content);
$data->message = $message;
$data->branch = $branch;
if ($authorName !== null || $authorEmail !== null)
{
$data->author = new \stdClass();
if ($authorName !== null)
{
$data->author->name = $authorName;
}
if ($authorEmail !== null)
{
$data->author->email = $authorEmail;
}
}
if ($committerName !== null || $committerEmail !== null)
{
$data->committer = new \stdClass();
if ($committerName !== null)
{
$data->committer->name = $committerName;
}
if ($committerEmail !== null)
{
$data->committer->email = $committerEmail;
}
}
if ($newBranch !== null)
{
$data->new_branch = $newBranch;
}
if ($authorDate !== null || $committerDate !== null)
{
$data->dates = new \stdClass();
if ($authorDate !== null)
{
$data->dates->author = $authorDate;
}
if ($committerDate !== null)
{
$data->dates->committer = $committerDate;
}
}
if ($signoff !== null)
{
$data->signoff = $signoff;
}
// Send the post request.
return $this->response->get(
$this->http->json()->put(
$this->uri->get($path), json_encode($data)
), 201
);
}
/**
* Get the metadata of all the entries of the root directory.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string|null $ref The name of the commit/branch/tag. Default the repository's default branch (usually master).
*
* @return array|null
* @since 5.1.1
**/
public function root(string $owner, string $repo, ?string $ref = null): ?array
{
return $this->metadata($owner, $repo, '', $ref);
}
/**
* Update a file in a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file path.
* @param string $content The file content.
* @param string $message The commit message.
* @param string $sha The blob SHA of the file.
* @param string $branch The branch name. Defaults to the repository's default branch.
* @param string|null $authorName The author name. Defaults to the authenticated user.
* @param string|null $authorEmail The author email. Defaults to the authenticated user.
* @param string|null $committerName The committer name. Defaults to the authenticated user.
* @param string|null $committerEmail The committer email. Defaults to the authenticated user.
* @param string|null $authorDate The author date.
* @param string|null $committerDate The committer date.
* @param string|null $fromPath The original file path to move/rename.
* @param string|null $newBranch The new branch to create from the specified branch.
* @param bool|null $signoff Add a Signed-off-by trailer.
*
* @return object|null
* @since 5.1.1
**/
public function update(
string $owner,
string $repo,
string $filepath,
string $content,
string $message,
string $sha,
string $branch = 'master',
?string $authorName = null,
?string $authorEmail = null,
?string $committerName = null,
?string $committerEmail = null,
?string $authorDate = null,
?string $committerDate = null,
?string $fromPath = null,
?string $newBranch = null,
?bool $signoff = null
): ?object {
// Build the request path.
$path = "/repos/{$owner}/{$repo}/contents/{$filepath}";
// Set the file data.
$data = new \stdClass();
$data->content = base64_encode($content);
$data->message = $message;
$data->branch = $branch;
$data->sha = $sha;
if ($authorName !== null || $authorEmail !== null)
{
$data->author = new \stdClass();
if ($authorName !== null)
{
$data->author->name = $authorName;
}
if ($authorEmail !== null)
{
$data->author->email = $authorEmail;
}
}
if ($committerName !== null || $committerEmail !== null)
{
$data->committer = new \stdClass();
if ($committerName !== null)
{
$data->committer->name = $committerName;
}
if ($committerEmail !== null)
{
$data->committer->email = $committerEmail;
}
}
if ($authorDate !== null || $committerDate !== null)
{
$data->dates = new \stdClass();
if ($authorDate !== null)
{
$data->dates->author = $authorDate;
}
if ($committerDate !== null)
{
$data->dates->committer = $committerDate;
}
}
if ($fromPath !== null)
{
$data->from_path = $fromPath;
}
if ($newBranch !== null)
{
$data->new_branch = $newBranch;
}
if ($signoff !== null)
{
$data->signoff = $signoff;
}
// Send the put request.
return $this->response->get(
$this->http->json()->put(
$this->uri->get($path),
json_encode($data)
)
);
}
/**
* Delete a file in a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file path.
* @param string $message The commit message.
* @param string $sha The blob SHA of the file.
* @param string|null $branch The branch name (optional).
* @param string|null $authorName The author name (optional).
* @param string|null $authorEmail The author email (optional).
* @param string|null $committerName The committer name (optional).
* @param string|null $committerEmail The committer email (optional).
* @param string|null $authorDate The author date (optional).
* @param string|null $committerDate The committer date (optional).
* @param string|null $newBranch The new branch name (optional).
* @param bool|null $signoff Add a Signed-off-by trailer (optional).
*
* @return object|null
* @since 5.1.1
**/
public function delete(
string $owner,
string $repo,
string $filepath,
string $message,
string $sha,
?string $branch = null,
?string $authorName = null,
?string $authorEmail = null,
?string $committerName = null,
?string $committerEmail = null,
?string $authorDate = null,
?string $committerDate = null,
?string $newBranch = null,
?bool $signoff = null
): ?object {
// Build the request path.
$path = "/repos/{$owner}/{$repo}/contents/{$filepath}";
// Set the file data.
$data = new \stdClass();
$data->message = $message;
$data->sha = $sha;
if ($branch !== null) {
$data->branch = $branch;
}
if ($authorName !== null || $authorEmail !== null)
{
$data->author = new \stdClass();
if ($authorName !== null)
{
$data->author->name = $authorName;
}
if ($authorEmail !== null)
{
$data->author->email = $authorEmail;
}
}
if ($committerName !== null || $committerEmail !== null)
{
$data->committer = new \stdClass();
if ($committerName !== null)
{
$data->committer->name = $committerName;
}
if ($committerEmail !== null)
{
$data->committer->email = $committerEmail;
}
}
if ($authorDate !== null || $committerDate !== null)
{
$data->dates = new \stdClass();
if ($authorDate !== null)
{
$data->dates->author = $authorDate;
}
if ($committerDate !== null)
{
$data->dates->committer = $committerDate;
}
}
if ($newBranch !== null)
{
$data->new_branch = $newBranch;
}
if ($signoff !== null)
{
$data->signoff = $signoff;
}
// Send the delete request.
return $this->response->get(
$this->http->json()->delete(
$this->uri->get($path), [], null,
json_encode($data)
)
);
}
/**
* Get the EditorConfig definitions of a file in a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file path.
* @param string|null $ref The name of the commit/branch/tag.
*
* @return string|null
* @since 5.1.1
**/
public function editor(string $owner, string $repo, string $filepath, string $ref = null): ?string
{
// Not supported in GitHub
return null;
}
/**
* Get the blob of a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $sha The SHA hash of the blob.
*
* @return object|null
* @since 5.1.1
**/
public function blob(string $owner, string $repo, string $sha): ?object
{
// Build the request path.
$path = "/repos/{$owner}/{$repo}/git/blobs/{$sha}";
// Send the get request.
return $this->response->get(
$this->http->json()->get(
$this->uri->get($path)
)
);
}
}

View File

@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@@ -0,0 +1,88 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Github\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Github\Utilities\Http;
use VDM\Joomla\Github\Utilities\Uri;
use VDM\Joomla\Github\Utilities\Response;
/**
* The Github Utilities Service
*
* @since 5.1.1
*/
class Utilities implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 5.1.1
*/
public function register(Container $container)
{
$container->alias(Http::class, 'Github.Utilities.Http')
->share('Github.Utilities.Http', [$this, 'getHttp'], true);
$container->alias(Uri::class, 'Github.Utilities.Uri')
->share('Github.Utilities.Uri', [$this, 'getUri'], true);
$container->alias(Response::class, 'Github.Utilities.Response')
->share('Github.Utilities.Response', [$this, 'getResponse'], true);
}
/**
* Get the Http class
*
* @param Container $container The DI container.
*
* @return Http
* @since 5.1.1
*/
public function getHttp(Container $container): Http
{
return new Http();
}
/**
* Get the Uri class
*
* @param Container $container The DI container.
*
* @return Uri
* @since 5.1.1
*/
public function getUri(Container $container): Uri
{
return new Uri();
}
/**
* Get the Response class
*
* @param Container $container The DI container.
*
* @return Response
* @since 5.1.1
*/
public function getResponse(Container $container): Response
{
return new Response();
}
}

View File

@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@@ -0,0 +1,163 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Github\Utilities;
use Joomla\CMS\Http\Http as JoomlaHttp;
use Joomla\Registry\Registry;
/**
* The Github Http
*
* @since 5.1.1
*/
final class Http extends JoomlaHttp
{
/**
* The token
*
* @var string|null
* @since 5.1.1
*/
protected ?string $_token_; // to avoid collisions (but allow swapping)
/**
* The GitHub API version header
*
* @var string
* @since 5.1.1
*/
protected string $apiVersion;
/**
* The GitHub default headers
*
* @var string
* @since 5.1.1
*/
protected array $defaultHeaders;
/**
* Constructor.
*
* @param string|null $token The Gitea API token.
* @param string $version GitHub API Version (e.g. 2022-11-28)
*
* @since 5.1.1
* @throws \InvalidArgumentException
**/
public function __construct(?string $token = null, string $version = '2022-11-28')
{
$this->apiVersion = $version;
$this->defaultHeaders = [
'Content-Type' => 'application/json',
'Accept' => 'application/vnd.github+json',
'X-GitHub-Api-Version' => $this->apiVersion
];
// setup config
$config = [
'userAgent' => 'JoomlaGitHub/3.0',
'headers' => $this->defaultHeaders
];
// add the token if given
if (is_string($token) && !empty($token))
{
$config['headers']['Authorization'] = 'Bearer ' . $token;
$this->_token_ = $token;
}
$options = new Registry($config);
// run parent constructor
parent::__construct($options);
}
/**
* Change the Token.
*
* @param string $token The Gitea API token.
*
* @since 5.1.1
**/
public function setToken(string $token): void
{
// get the current headers
$headers = (array) $this->getOption('headers', $this->defaultHeaders);
if (empty($token))
{
unset($headers['Authorization']);
}
else
{
// add the token
$headers['Authorization'] = 'Bearer ' . $token;
$this->_token_ = $token;
}
$this->setOption('headers', $headers);
}
/**
* Get the Token.
*
* @return string|null
* @since 5.1.1
**/
public function getToken(): ?string
{
return $this->_token_ ?? null;
}
/**
* Set Accept header to 'application/vnd.github+json'
*
* @return static
* @since 5.1.1
*/
public function json(): self
{
$this->setAcceptHeader('application/vnd.github+json');
return $this;
}
/**
* Set Accept header to 'application/vnd.github.raw+json'
*
* @return static
* @since 5.1.1
*/
public function raw(): self
{
$this->setAcceptHeader('application/vnd.github.raw+json');
return $this;
}
/**
* Set Accept header
*
* @return void
* @since 5.1.1
*/
protected function setAcceptHeader(string $value): void
{
$headers = (array) $this->getOption('headers', $this->defaultHeaders);
$headers['Accept'] = $value;
$this->setOption('headers', $headers);
}
}

View File

@@ -0,0 +1,169 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Github\Utilities;
use Joomla\Http\Response as JoomlaResponse;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* The Github Response
*
* @since 5.1.1
*/
final class Response
{
/**
* Process the response and decode it.
*
* @param JoomlaResponse $response The response.
* @param integer $expectedCode The expected "good" code.
* @param mixed $default The default if body not have length
*
* @return mixed
*
* @since 5.1.1
* @throws \DomainException
**/
public function get(JoomlaResponse $response, int $expectedCode = 200, $default = null)
{
// Validate the response code.
if ($response->code != $expectedCode)
{
// Decode the error response and throw an exception.
$message = $this->error($response);
throw new \DomainException("Invalid response received from GitHub API. {$message}", $response->code);
}
return $this->body($response, $default);
}
/**
* Process the response and decode it. (when we have multiple success codes)
*
* @param JoomlaResponse $response The response.
* @param array [$expectedCode => $default] The expected "good" code. and The default if body not have length
*
* @return mixed
*
* @since 5.1.1
* @throws \DomainException
**/
public function get_(JoomlaResponse $response, array $validate = [200 => null])
{
// Validate the response code.
if (!array_key_exists($response->code, $validate))
{
// Decode the error response and throw an exception.
$message = $this->error($response);
throw new \DomainException("Invalid response received from GitHub API. {$message}", $response->code);
}
return $this->body($response, $validate[$response->code]);
}
/**
* Return the body from the response
*
* @param JoomlaResponse $response The response.
* @param mixed $default The default if body not have length
*
* @return mixed
* @since 5.1.1
**/
protected function body(JoomlaResponse $response, $default = null)
{
$body = method_exists($response, 'getBody')
? (string) $response->getBody()
: ($response->body ?? null);
// check that we have a body
if ($body !== null && StringHelper::check($body))
{
if (JsonHelper::check($body))
{
$body = json_decode((string) $body);
if (isset($body->content) && isset($body->encoding) && $body->encoding === 'base64')
{
$body->decoded_content = base64_decode((string) $body->content);
}
}
return $body;
}
return $default;
}
/**
* Extract an error message from a response object.
*
* @param JoomlaResponse $response The response object.
*
* @return string The extracted error message, or an empty string.
* @since 5.1.1
*/
protected function error(JoomlaResponse $response): string
{
// Try to get the raw response body
$body = method_exists($response, 'getBody') ? (string) $response->getBody() : '';
// Try to decode as JSON object
$errorData = JsonHelper::check($body) ? json_decode($body) : null;
if (is_object($errorData))
{
// GitHub's error structure may have a message and/or an errors array
if (!empty($errorData->message)) {
$errorMsg = $errorData->message;
if (!empty($errorData->errors) && is_array($errorData->errors)) {
$details = [];
foreach ($errorData->errors as $err) {
if (is_object($err)) {
$details[] = trim(
($err->resource ?? '') . ' ' .
($err->field ?? '') . ' ' .
($err->code ?? '')
);
} else {
$details[] = (string) $err;
}
}
$errorMsg .= ' (' . implode('; ', array_filter($details)) . ')';
}
return $errorMsg;
}
return json_encode($errorData, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}
// Fallback to reason phrase or body
if (!empty($body))
{
return $body;
}
return method_exists($response, 'getReasonPhrase')
? $response->getReasonPhrase()
: 'No error information found in GitHub API response.';
}
}

View File

@@ -0,0 +1,169 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Github\Utilities;
use Joomla\Uri\Uri as JoomlaUri;
/**
* The Github Uri
*
* @since 5.1.1
*/
final class Uri
{
/**
* The api endpoint
*
* @var string
* @since 5.1.1
*/
private string $endpoint;
/**
* The api version
*
* @var string
* @since 5.1.1
*/
private string $version;
/**
* The api URL
*
* @var string
* @since 5.1.1
*/
private string $url;
/**
* Constructor
*
* @param string $url URL to the github system
* example: https://api.github.com
* @param string $endpoint Endpoint to the gitea system
* @param string $version Version to the gitea system
*
* @since 5.1.1
**/
public function __construct(
string $url = 'https://api.github.com',
string $endpoint = '',
string $version = 'v3')
{
// set the API details
$this->setUrl($url);
//$this->setEndpoint($endpoint);
//$this->setVersion($version);
}
/**
* Method to build and return a full request URL for the request. This method will
* add appropriate pagination details if necessary and also prepend the API url
* to have a complete URL for the request.
*
* @param string $path URL to inflect
*
* @return JoomlaUri
* @since 5.1.1
**/
public function get(string $path): JoomlaUri
{
// GitHub API does not use version in URL (normally passed in Accept headers)
// But we maintain compatibility with existing interface
$uri = new JoomlaUri($this->api() . ltrim($path, '/'));
return $uri;
}
/**
* Get the full API URL
*
* @return string
* @since 5.1.1
**/
public function api(): string
{
// Ensure trailing slash on base URL
return rtrim($this->url, '/') . '/';
/**
// GitHub typically does not use endpoint/version in URL
// But to preserve interface, we include them conditionally
$segments = [];
if (!empty($this->endpoint))
{
$segments[] = trim($this->endpoint, '/');
}
if (!empty($this->version))
{
$segments[] = trim($this->version, '/');
}
return $base . (empty($segments) ? '' : implode('/', $segments) . '/');
**/
}
/**
* Set the URL of the API
*
* @param string $url URL to your github system
* example: https://api.github.com
*
* @return void
* @since 5.1.1
**/
public function setUrl(string $url)
{
$this->url = $url;
}
/**
* Get the URL of the API
*
* @return string|null
* @since 5.1.1
**/
public function getUrl(): ?string
{
return $this->url ?? null;
}
/**
* Set the endpoint of the API
*
* @param string $endpoint endpoint to your github API
*
* @return void
* @since 5.1.1
private function setEndpoint(string $endpoint)
{
$this->endpoint = $endpoint;
}
**/
/**
* Set the version of the API
*
* @param string $version version to your github API
*
* @return void
* @since 3.2.0
private function setVersion($version)
{
$this->version = $version;
}
**/
}

View File

@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>