Large changes to inter-object interfaces + More

+ Created a new core interface (called RequestChainable) and applied it to most of the objects using a trait
+ Altered the `__construct()` and `fromJson()` methods of all model classes by replacing the second parameter ($apiRequester) with a $caller parameter
+ Altered the  `__construct()` method of all requester classes to make them accept $client by reference instead of by value
+ Altered the  `__construct()` method of all requester classes by replacing the second parameter ($authToken) with a $caller parameter
+ Changed the name of several methods and properties
+ Altered several docblocks
This commit is contained in:
Benjamin Blake
2020-02-26 20:23:06 -07:00
parent 57bf45938f
commit 70f978847e
21 changed files with 568 additions and 309 deletions

View File

@ -6,27 +6,40 @@ use Gitea\Client;
use Gitea\Api\Interfaces\ApiRequesterInterface;
use \stdClass;
use Gitea\Model\Interfaces\ApiModelInterface;
use \JsonSerializable;
abstract class AbstractApiModel implements ApiModelInterface, JsonSerializable
// Traits
use Gitea\Core\Traits\RequestChainable;
use Gitea\Model\Interfaces\ApiModelInterface;
use Gitea\Core\Interfaces\RequestChainableInterface;
abstract class AbstractApiModel implements ApiModelInterface, JsonSerializable, RequestChainableInterface
{
use RequestChainable;
/**
* Creates a new API model object
*
* @author Benjamin Blake (sitelease.ca)
*
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param mixed $args The organization visibility.
*/
public function __construct(Client &$client , ?object $caller, ...$args) {
$this->setClient($client);
$this->setCaller($caller);
}
/**
* The Gitea client that originally made the
* Api request for this object
*
* @var Client
*/
protected $giteaClient;
/**
* The Api request object that created
* this model object
*
* @var ApiRequesterInterface
*/
protected $apiRequester;
protected $client;
/**
* Create a new API model object from a JSON map object
@ -34,19 +47,19 @@ abstract class AbstractApiModel implements ApiModelInterface, JsonSerializable
* Example:
* ```
* ClassName::fromJson(
* $giteaClient,
* $apiRequester,
* $client,
* $this,
* json_decode($jsonString)
* );
* ```
*
* @author Benjamin Blake (sitelease.ca)
*
* @param object $giteaClient The Gitea client that originally made the request for this object's data
* @param object $apiRequester The Api requester that created this object
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param object $map A JSON data object
*/
static function fromJson(object $giteaClient, object $apiRequester, object $map) {
static function fromJson(object &$client , ?object $caller, object $map) {
trigger_error("The abstract 'fromJson()' method must be overwritten");
return false;
}
@ -65,38 +78,25 @@ abstract class AbstractApiModel implements ApiModelInterface, JsonSerializable
}
/**
* Get the Gitea client that originally made the
* Api request for this object
* Get the gitea client (by reference)
*
* @author Benjamin Blake (sitelease.ca)
*
* @return Client
*/
public function getGiteaClient() {
return $this->giteaClient;
}
public function setGiteaClient($object): self {
$this->giteaClient = $object;
return $this;
public function getClient(): Client {
return $this->client;
}
/**
* Get the Api request object that created
* this model object
* Set the gitea client (by reference)
*
* @author Benjamin Blake (sitelease.ca)
*
* @return ApiRequesterInterface
* @param Client $client
* @return self
*/
public function getApiRequester() {
return $this->apiRequester;
}
public function setApiRequester($object): self {
$this->apiRequester = $object;
public function setClient(Client &$client): self {
$this->client = $client;
return $this;
}
}

View File

@ -5,6 +5,7 @@ namespace Gitea\Model;
use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\UriInterface;
use Gitea\Client;
use Gitea\Model\PayloadCommit;
use \InvalidArgumentException;
@ -32,13 +33,12 @@ class Branch extends AbstractApiModel {
/**
* Creates a new branch
* @param object $giteaClient The Gitea client that originally made the request for this object's data
* @param object $apiRequester The Api requester that created this object
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param string $name The branch name
*/
function __construct(object $giteaClient, object $apiRequester, ...$args) {
$this->setGiteaClient($giteaClient);
$this->setApiRequester($apiRequester);
public function __construct(Client &$client , ?object $caller, ...$args) {
parent::__construct($client, $caller, $args);
if (count($args) >= 1) {
$name = $args[0];
if (!is_string($name)) {
@ -54,20 +54,20 @@ class Branch extends AbstractApiModel {
/**
* Creates a new branch from the specified JSON map.
* @param object $giteaClient The Gitea client that originally made the request for this object's data
* @param object $apiRequester The Api requester that created this object
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param object $map A JSON map representing an branch.
* @return static The instance corresponding to the specified JSON map.
*/
static function fromJson(object $giteaClient, object $apiRequester, object $map): self {
static function fromJson(object &$client , ?object $caller, object $map): self {
return (
new static(
$giteaClient,
$apiRequester,
$client,
$caller,
isset($map->name) && is_string($map->name) ? $map->name : ''
)
)
->setCommit(isset($map->commit) && is_object($map->commit) ? PayloadCommit::fromJson($giteaClient, $apiRequester, $map->commit) : null)
->setCommit(isset($map->commit) && is_object($map->commit) ? PayloadCommit::fromJson($client, null, $map->commit) : null)
->setProtected(isset($map->protected) && is_bool($map->protected) ? $map->protected : true)
->setCanUserPush(isset($map->user_can_push) && is_bool($map->user_can_push) ? $map->user_can_push : false)
->setUserCanMerge(isset($map->user_can_merge) && is_bool($map->user_can_merge) ? $map->user_can_merge : false);

View File

@ -15,11 +15,11 @@ interface ApiModelInterface
*
* @author Benjamin Blake (sitelease.ca)
*
* @param object $giteaClient The Gitea client that originally made the request for this object's data
* @param object $apiRequester The Api requester that created this object
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param mixed $args The organization visibility.
*/
public function __construct(object $giteaClient, object $apiRequester, ...$args);
public function __construct(Client &$client , ?object $caller, ...$args);
/**
* Create a new API model object from a JSON map object
@ -27,19 +27,19 @@ interface ApiModelInterface
* Example:
* ```
* ClassName::fromJson(
* $giteaClient,
* $apiRequester,
* $client,
* $this,
* json_decode($jsonString)
* );
* ```
*
* @author Benjamin Blake (sitelease.ca)
*
* @param object $giteaClient The Gitea client that originally made the request for this object's data
* @param object $apiRequester The Api requester that created this object
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param object $map A JSON data object
*/
static function fromJson(object $giteaClient, object $apiRequester, object $map);
static function fromJson(object &$client , ?object $caller, object $map);
/**
* Convert this Api model object to a JSON map.
@ -54,24 +54,21 @@ interface ApiModelInterface
public function jsonSerialize(): \stdClass;
/**
* Get the Gitea client that originally made the
* Api request for this object
* Get the gitea client (by reference)
*
* @author Benjamin Blake (sitelease.ca)
*
* @return Client
*/
public function getGiteaClient();
public function getClient(): Client;
/**
* Get the Api request object that created
* this model object
* Set the gitea client (by reference)
*
* @author Benjamin Blake (sitelease.ca)
*
* @return ApiRequesterInterface
* @param Client $client
* @return self
*/
public function getApiRequester();
public function setClient(Client &$client): self;
}

View File

@ -5,6 +5,8 @@ namespace Gitea\Model;
use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\UriInterface;
use Gitea\Client;
use \InvalidArgumentException;
use Gitea\Model\Abstracts\AbstractApiModel;
@ -38,14 +40,13 @@ class Organization extends AbstractApiModel {
/**
* Creates a new organization.
* @param object $giteaClient The Gitea client that originally made the request for this object's data
* @param object $apiRequester The Api requester that created this object
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param string $username The organization name.
* @param string $visibility The organization visibility.
*/
function __construct(object $giteaClient, object $apiRequester, ...$args) {
$this->setGiteaClient($giteaClient);
$this->setApiRequester($apiRequester);
public function __construct(Client &$client , ?object $caller, ...$args) {
parent::__construct($client, $caller, $args);
if (count($args) >= 2) {
$username = $args[0];
$visibility = $args[1];
@ -67,14 +68,16 @@ class Organization extends AbstractApiModel {
/**
* Creates a new organization from the specified JSON map.
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param object $map A JSON map representing an organization.
* @return static The instance corresponding to the specified JSON map.
*/
static function fromJson(object $giteaClient, object $apiRequester, object $map): self {
static function fromJson(object &$client , ?object $caller, object $map): self {
return (
new static(
$giteaClient,
$apiRequester,
$client,
$caller,
isset($map->username) && is_string($map->username) ? $map->username : '',
isset($map->visibility) && is_string($map->visibility) ? $map->visibility : 'private'
)

View File

@ -5,6 +5,8 @@ namespace Gitea\Model;
use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\UriInterface;
use Gitea\Client;
use Gitea\Model\Abstracts\AbstractApiModel;
/** Represents a Gitea owner. */
@ -36,14 +38,13 @@ class Owner extends AbstractApiModel {
/**
* Creates a new owner.
* @param object $giteaClient The Gitea client that originally made the request for this object's data
* @param object $apiRequester The Api requester that created this object
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param int $id The owner identifier.
* @param string $login The name of the Gitea account.
*/
function __construct(object $giteaClient, object $apiRequester, ...$args) {
$this->setGiteaClient($giteaClient);
$this->setApiRequester($apiRequester);
public function __construct(Client &$client , ?object $caller, ...$args) {
parent::__construct($client, $caller, $args);
if (count($args) >= 2) {
$id = $args[0];
$login = $args[1];
@ -65,16 +66,16 @@ class Owner extends AbstractApiModel {
/**
* Creates a new owner from the specified JSON map.
* @param object $giteaClient The Gitea client that originally made the request for this object's data
* @param object $apiRequester The Api requester that created this object
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param object $map A JSON map representing a owner.
* @return static The instance corresponding to the specified JSON map.
*/
static function fromJson(object $giteaClient, object $apiRequester, object $map): self {
static function fromJson(object &$client , ?object $caller, object $map): self {
return (
new static(
$giteaClient,
$apiRequester,
$client,
$caller,
isset($map->id) && is_int($map->id) ? $map->id : -1,
isset($map->login) && is_string($map->login) ? $map->login : ''
)

View File

@ -5,6 +5,7 @@ namespace Gitea\Model;
use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\UriInterface;
use Gitea\Client;
use Gitea\Model\PayloadUser;
use Gitea\Model\PayloadCommitVerification;
@ -38,14 +39,13 @@ class PayloadCommit extends AbstractApiModel {
/**
* Creates a new payload commit.
* @param object $giteaClient The Gitea client that originally made the request for this object's data
* @param object $apiRequester The Api requester that created this object
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param string $id The commit hash.
* @param string $message The commit message.
*/
function __construct(object $giteaClient, object $apiRequester, ...$args) {
$this->setGiteaClient($giteaClient);
$this->setApiRequester($apiRequester);
public function __construct(Client &$client , ?object $caller, ...$args) {
parent::__construct($client, $caller, $args);
if (count($args) >= 2) {
$id = $args[0];
$message = $args[1];
@ -67,25 +67,25 @@ class PayloadCommit extends AbstractApiModel {
/**
* Creates a new commit from the specified JSON map.
* @param object $giteaClient The Gitea client that originally made the request for this object's data
* @param object $apiRequester The Api requester that created this object
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param object $map A JSON map representing a commit.
* @return static The instance corresponding to the specified JSON map.
*/
static function fromJson(object $giteaClient, object $apiRequester, object $map): self {
static function fromJson(object &$client , ?object $caller, object $map): self {
return (
new static(
$giteaClient,
$apiRequester,
$client,
$caller,
isset($map->id) && is_string($map->id) ? $map->id : '',
isset($map->message) && is_string($map->message) ? $map->message : ''
)
)
->setAuthor(isset($map->author) && is_object($map->author) ? PayloadUser::fromJson($giteaClient, $apiRequester, $map->author) : null)
->setCommitter(isset($map->committer) && is_object($map->committer) ? PayloadUser::fromJson($giteaClient, $apiRequester, $map->committer) : null)
->setAuthor(isset($map->author) && is_object($map->author) ? PayloadUser::fromJson($client, null, $map->author) : null)
->setCommitter(isset($map->committer) && is_object($map->committer) ? PayloadUser::fromJson($client, null, $map->committer) : null)
->setTimestamp(isset($map->timestamp) && is_string($map->timestamp) ? new \DateTime($map->timestamp) : null)
->setUrl(isset($map->url) && is_string($map->url) ? new Uri($map->url) : null)
->setVerification(isset($map->verification) && is_object($map->verification) ? PayloadCommitVerification::fromJson($giteaClient, $apiRequester, $map->verification) : null);
->setVerification(isset($map->verification) && is_object($map->verification) ? PayloadCommitVerification::fromJson($client, null, $map->verification) : null);
}
/**

View File

@ -5,6 +5,8 @@ namespace Gitea\Model;
use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\UriInterface;
use Gitea\Client;
use \InvalidArgumentException;
use Gitea\Model\Abstracts\AbstractApiModel;
@ -26,14 +28,12 @@ class PayloadCommitVerification extends AbstractApiModel {
/**
* Creates a new verification of a payload commit.
* @param object $giteaClient The Gitea client that originally made the request for this object's data
* @param object $apiRequester The Api requester that created this object
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param bool $isVerified Value indicating whether the verification has succeeded.
*/
function __construct(object $giteaClient, object $apiRequester, ...$args) {
$this->setGiteaClient($giteaClient);
$this->setApiRequester($apiRequester);
public function __construct(Client &$client , ?object $caller, ...$args) {
parent::__construct($client, $caller, $args);
if (count($args) >= 1) {
$isVerified = $args[0];
if (!is_bool($isVerified)) {
@ -49,16 +49,16 @@ class PayloadCommitVerification extends AbstractApiModel {
/**
* Creates a new commit from the specified JSON map.
* @param object $giteaClient The Gitea client that originally made the request for this object's data
* @param object $apiRequester The Api requester that created this object
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param object $map A JSON map representing a commit.
* @return static The instance corresponding to the specified JSON map.
*/
static function fromJson(object $giteaClient, object $apiRequester, object $map): self {
static function fromJson(object &$client , ?object $caller, object $map): self {
return (
new static(
$giteaClient,
$apiRequester,
$client,
$caller,
isset($map->verified) && is_bool($map->verified) ? $map->verified : false
)
)

View File

@ -5,6 +5,8 @@ namespace Gitea\Model;
use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\UriInterface;
use Gitea\Client;
use \stdClass;
use \InvalidArgumentException;
@ -24,13 +26,12 @@ class PayloadUser extends AbstractApiModel {
/**
* Creates a new payload user.
* @param object $giteaClient The Gitea client that originally made the request for this object's data
* @param object $apiRequester The Api requester that created this object
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param string $username The name of the Gitea account.
*/
function __construct(object $giteaClient, object $apiRequester, ...$args) {
$this->setGiteaClient($giteaClient);
$this->setApiRequester($apiRequester);
public function __construct(Client &$client , ?object $caller, ...$args) {
parent::__construct($client, $caller, $args);
if (count($args) >= 1) {
$username = $args[0];
if (!is_string($username)) {
@ -46,16 +47,16 @@ class PayloadUser extends AbstractApiModel {
/**
* Creates a new user from the specified JSON map.
* @param object $giteaClient The Gitea client that originally made the request for this object's data
* @param object $apiRequester The Api requester that created this object
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param object $map A JSON map representing a user.
* @return static The instance corresponding to the specified JSON map.
*/
static function fromJson(object $giteaClient, object $apiRequester, object $map): self {
static function fromJson(object &$client , ?object $caller, object $map): self {
return (
new static(
$giteaClient,
$apiRequester,
$client,
$caller,
isset($map->username) && is_string($map->username) ? $map->username : ''
)
)

View File

@ -5,6 +5,8 @@ namespace Gitea\Model;
use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\UriInterface;
use Gitea\Client;
use \InvalidArgumentException;
use Gitea\Model\Abstracts\AbstractApiModel;
@ -23,15 +25,14 @@ class Permission extends AbstractApiModel {
/**
* Creates a new permission.
* @param object $giteaClient The Gitea client that originally made the request for this object's data
* @param object $apiRequester The Api requester that created this object
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param bool $admin Value indicating whether administrator access is allowed.
* @param bool $pull Value indicating whether pull is allowed.
* @param bool $push Value indicating whether push is allowed.
*/
function __construct(object $giteaClient, object $apiRequester, ...$args) {
$this->setGiteaClient($giteaClient);
$this->setApiRequester($apiRequester);
public function __construct(Client &$client , ?object $caller, ...$args) {
parent::__construct($client, $caller, $args);
if (count($args) >= 2) {
$admin = $args[0];
$pull = $args[1];
@ -57,15 +58,15 @@ class Permission extends AbstractApiModel {
/**
* Creates a new user from the specified JSON map.
* @param object $giteaClient The Gitea client that originally made the request for this object's data
* @param object $apiRequester The Api requester that created this object
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param object $map A JSON map representing a user.
* @return static The instance corresponding to the specified JSON map.
*/
static function fromJson(object $giteaClient, object $apiRequester, object $map): self {
static function fromJson(object &$client , ?object $caller, object $map): self {
return new static(
$giteaClient,
$apiRequester,
$client,
$caller,
isset($map->admin) && is_bool($map->admin) ? $map->admin : false,
isset($map->pull) && is_bool($map->pull) ? $map->pull : false,
isset($map->push) && is_bool($map->push) ? $map->push : false

View File

@ -1,9 +1,11 @@
<?php declare(strict_types=1);
namespace Gitea\Model;
use GuzzleHttp\Psr7\{Uri};
use Psr\Http\Message\{UriInterface};
use Gitea\Client;
use Gitea\Collections\ApiItemCollection;
use Gitea\Model\Owner;
use Gitea\Api\Repositories;
@ -88,14 +90,13 @@ class Repository extends AbstractApiModel {
/**
* Creates a new repository.
* @param object $giteaClient The Gitea client that originally made the request for this object's data
* @param object $apiRequester The Api requester that created this object
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param int $id The repository identifier.
* @param string $fullName The full name of the repository.
*/
function __construct(object $giteaClient, object $apiRequester, ...$args) {
$this->setGiteaClient($giteaClient);
$this->setApiRequester($apiRequester);
public function __construct(Client &$client , ?object $caller, ...$args) {
parent::__construct($client, $caller, $args);
if (count($args) >= 2) {
$id = $args[0];
$fullName = $args[1];
@ -117,14 +118,16 @@ class Repository extends AbstractApiModel {
/**
* Creates a new repository from the specified JSON map.
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param object $map A JSON map representing a repository.
* @return static The instance corresponding to the specified JSON map.
*/
static function fromJson(object $giteaClient, object $apiRequester, object $map): self {
static function fromJson(object &$client , ?object $caller, object $map): self {
return (
new static(
$giteaClient,
$apiRequester,
$client,
$caller,
isset($map->id) && is_int($map->id) ? $map->id : -1,
isset($map->full_name) && is_string($map->full_name) ? $map->full_name : ''
)
@ -140,9 +143,9 @@ class Repository extends AbstractApiModel {
->setMirror(isset($map->mirror) && is_bool($map->mirror) ? $map->mirror : false)
->setName(isset($map->name) && is_string($map->name) ? $map->name : '')
->setOpenIssuesCount(isset($map->open_issues_count) && is_int($map->open_issues_count) ? $map->open_issues_count : 0)
->setOwner(isset($map->owner) && is_object($map->owner) ? Owner::fromJson($giteaClient, $apiRequester, $map->owner) : null)
->setParent(isset($map->parent) && is_object($map->parent) ? Repository::fromJson($giteaClient, $apiRequester, $map->parent) : null)
->setPermissions(isset($map->permissions) && is_object($map->permissions) ? Permission::fromJson($giteaClient, $apiRequester, $map->permissions) : null)
->setOwner(isset($map->owner) && is_object($map->owner) ? Owner::fromJson($client, null, $map->owner) : null)
->setParent(isset($map->parent) && is_object($map->parent) ? Repository::fromJson($client, null, $map->parent) : null)
->setPermissions(isset($map->permissions) && is_object($map->permissions) ? Permission::fromJson($client, null, $map->permissions) : null)
->setPrivate(isset($map->private) && is_bool($map->private) ? $map->private : false)
->setSize(isset($map->size) && is_int($map->size) ? $map->size : 0)
->setSshUrl(isset($map->ssh_url) && is_string($map->ssh_url) ? new Uri($map->ssh_url) : null)
@ -602,8 +605,8 @@ class Repository extends AbstractApiModel {
{
$owner = $this->getOwner();
if ($owner) {
$client = $this->getGiteaClient();
$repositoriesApi = new Repositories($client, $client->getAuthToken());
$client = $this->getClient();
$repositoriesApi = new Repositories($client, $this);
return $repositoriesApi->downloadArchive($owner->getUsername(), $this->getName(), $gitRef, $format);
}
}
@ -619,8 +622,8 @@ class Repository extends AbstractApiModel {
{
$owner = $this->getOwner();
if ($owner) {
$client = $this->getGiteaClient();
$branchesApi = new Branches($client, $client->getAuthToken());
$client = $this->getClient();
$branchesApi = new Branches($client, $this);
return $branchesApi->fromRepository($owner->getUsername(), $this->getName());
}
}
@ -636,8 +639,8 @@ class Repository extends AbstractApiModel {
{
$owner = $this->getOwner();
if ($owner) {
$client = $this->getGiteaClient();
$tagsApi = new Tags($client, $client->getAuthToken());
$client = $this->getClient();
$tagsApi = new Tags($client, $this);
return $tagsApi->fromRepository($owner->getUsername(), $this->getName());
}
}

View File

@ -5,6 +5,8 @@ namespace Gitea\Model;
use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\UriInterface;
use Gitea\Client;
use \InvalidArgumentException;
use Gitea\Model\Abstracts\AbstractApiModel;
@ -32,14 +34,13 @@ class Tag extends AbstractApiModel {
/**
* Creates a new tag
* @param object $giteaClient The Gitea client that originally made the request for this object's data
* @param object $apiRequester The Api requester that created this object
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param int $id The tag identifier
* @param string $name The tag name
*/
function __construct(object $giteaClient, object $apiRequester, ...$args) {
$this->setGiteaClient($giteaClient);
$this->setApiRequester($apiRequester);
public function __construct(Client &$client , ?object $caller, ...$args) {
parent::__construct($client, $caller, $args);
if (count($args) >= 2) {
$id = $args[0];
$name = $args[1];
@ -61,15 +62,15 @@ class Tag extends AbstractApiModel {
/**
* Creates a new tag from the specified JSON map.
* @param object $giteaClient The Gitea client that originally made the request for this object's data
* @param object $apiRequester The Api requester that created this object
* @param object $client The Gitea client that originally made the request for this object's data
* @param object|null $caller The object that called this method
* @param object $map A JSON map representing an tag.
* @return static The instance corresponding to the specified JSON map.
*/
static function fromJson(object $giteaClient, object $apiRequester, object $map): self {
static function fromJson(object &$client , ?object $caller, object $map): self {
$newTag = new static(
$giteaClient,
$apiRequester,
$client,
$caller,
isset($map->id) && is_int($map->id) ? $map->id : -1,
isset($map->name) && is_string($map->name) ? $map->name : ''
);