mirror of
https://github.com/sitelease/sugar-cube-client.git
synced 2025-10-31 20:12:29 +01:00
Replacing public properties by getters and setters
This commit is contained in:
@ -58,9 +58,8 @@ class PushEvent implements \JsonSerializable {
|
||||
|
||||
/**
|
||||
* Creates a new event.
|
||||
* @param array $config Name-value pairs that will be used to initialize the object properties.
|
||||
*/
|
||||
function __construct(array $config = []) {
|
||||
function __construct() {
|
||||
$this->commits = new \ArrayObject;
|
||||
}
|
||||
|
||||
@ -70,17 +69,16 @@ class PushEvent implements \JsonSerializable {
|
||||
* @return static The instance corresponding to the specified JSON map.
|
||||
*/
|
||||
static function fromJson(object $map): self {
|
||||
return new static([
|
||||
'after' => isset($map->after) && is_string($map->after) ? $map->after : '',
|
||||
'before' => isset($map->before) && is_string($map->before) ? $map->before : '',
|
||||
'compareUrl' => isset($map->compare_url) && is_string($map->compare_url) ? new Uri($map->compare_url) : null,
|
||||
'commits' => isset($map->commits) && is_array($map->commits) ? array_map([PayloadCommit::class, 'fromJson'], $map->commits) : [],
|
||||
'pusher' => isset($map->pusher) && is_object($map->pusher) ? User::fromJson($map->pusher) : null,
|
||||
'ref' => isset($map->ref) && is_string($map->ref) ? $map->ref : '',
|
||||
'repository' => isset($map->repository) && is_object($map->repository) ? Repository::fromJson($map->repository) : null,
|
||||
'secret' => isset($map->secret) && is_string($map->secret) ? $map->secret : '',
|
||||
'sender' => isset($map->sender) && is_object($map->sender) ? User::fromJson($map->sender) : null
|
||||
]);
|
||||
return (new static)
|
||||
->setAfter(isset($map->after) && is_string($map->after) ? $map->after : '')
|
||||
->setBefore(isset($map->before) && is_string($map->before) ? $map->before : '')
|
||||
->setCompareUrl(isset($map->compare_url) && is_string($map->compare_url) ? new Uri($map->compare_url) : null)
|
||||
->setCommits(isset($map->commits) && is_array($map->commits) ? array_map([PayloadCommit::class, 'fromJson'], $map->commits) : [])
|
||||
// TODO: 'pusher' => isset($map->pusher) && is_object($map->pusher) ? User::fromJson($map->pusher) : null)
|
||||
->setRef(isset($map->ref) && is_string($map->ref) ? $map->ref : '')
|
||||
// TODO: 'repository' => isset($map->repository) && is_object($map->repository) ? Repository::fromJson($map->repository) : null)
|
||||
->setSecret(isset($map->secret) && is_string($map->secret) ? $map->secret : '');
|
||||
// TODO: 'sender' => isset($map->sender) && is_object($map->sender) ? User::fromJson($map->sender) : null):
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,10 +139,10 @@ class PushEvent implements \JsonSerializable {
|
||||
'before' => $this->getBefore(),
|
||||
'compare_url' => ($url = $this->getCompareUrl()) ? (string) $url : null,
|
||||
'commits' => array_map(function(PayloadCommit $commit) { return $commit->jsonSerialize(); }, $this->getCommits()->getArrayCopy()),
|
||||
'pusher',
|
||||
'pusher' => 'TODO',
|
||||
'ref' => $this->getRef(),
|
||||
'repository',
|
||||
'sender'
|
||||
'repository' => 'TODO',
|
||||
'sender' => 'TODO'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ class PayloadCommitVerification implements \JsonSerializable {
|
||||
/**
|
||||
* @var bool Value indicating whether the verification has succeeded.
|
||||
*/
|
||||
private $isVerified = false;
|
||||
private $isVerified;
|
||||
|
||||
/**
|
||||
* @var string A custom message sent with the verification request.
|
||||
@ -29,9 +29,10 @@ class PayloadCommitVerification implements \JsonSerializable {
|
||||
|
||||
/**
|
||||
* Creates a new verification of a payload commit.
|
||||
* @param bool $isVerified Value indicating whether the verification has succeeded.
|
||||
*/
|
||||
function __construct(bool $isVerified = false) {
|
||||
// TODO $this->setVerified($isVerified);
|
||||
$this->setVerified($isVerified);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,12 +41,10 @@ class PayloadCommitVerification implements \JsonSerializable {
|
||||
* @return static The instance corresponding to the specified JSON map.
|
||||
*/
|
||||
static function fromJson(object $map): self {
|
||||
return new static([
|
||||
'isVerified' => isset($map->verified) && is_bool($map->verified) ? $map->verified : false,
|
||||
'payload' => isset($map->payload) && is_string($map->payload) ? $map->payload : '',
|
||||
'reason' => isset($map->reason) && is_string($map->reason) ? $map->reason : '',
|
||||
'signature' => isset($map->signature) && is_string($map->signature) ? $map->signature : ''
|
||||
]);
|
||||
return (new static(isset($map->verified) && is_bool($map->verified) ? $map->verified : false))
|
||||
->setPayload(isset($map->payload) && is_string($map->payload) ? $map->payload : '')
|
||||
->setReason(isset($map->reason) && is_string($map->reason) ? $map->reason : '')
|
||||
->setSignature(isset($map->signature) && is_string($map->signature) ? $map->signature : '');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,8 +72,8 @@ class PayloadCommitVerification implements \JsonSerializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @return bool
|
||||
* Gets a value indicating whether the verification has succeeded.
|
||||
* @return bool `true` if the verification has succeeded, otherwise `false`.
|
||||
*/
|
||||
function isVerified(): bool {
|
||||
return $this->isVerified;
|
||||
@ -92,4 +91,44 @@ class PayloadCommitVerification implements \JsonSerializable {
|
||||
'verified' => $this->isVerified()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the custom message sent with the verification request.
|
||||
* @param string $value A new custom message.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setPayload(string $value): self {
|
||||
$this->payload = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the message providing details about the verification.
|
||||
* @param string $value A new message providing details about the verification.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setReason(string $value): self {
|
||||
$this->reason = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the signing key used for the verification.
|
||||
* @param string $value The new signing key.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setSignature(string $value): self {
|
||||
$this->signature = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value indicating whether the verification has succeeded.
|
||||
* @param bool $value `true` if the verification has succeeded, otherwise `false`.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setVerified(bool $value): self {
|
||||
$this->isVerified = $value;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +20,15 @@ class PayloadUser implements \JsonSerializable {
|
||||
/**
|
||||
* @var string The name of the Gitea account.
|
||||
*/
|
||||
private $username = '';
|
||||
private $username;
|
||||
|
||||
/**
|
||||
* Creates a new payload user.
|
||||
* @param string $username The name of the Gitea account.
|
||||
*/
|
||||
function __construct(string $username) {
|
||||
$this->username = $username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new user from the specified JSON map.
|
||||
@ -28,11 +36,33 @@ class PayloadUser implements \JsonSerializable {
|
||||
* @return static The instance corresponding to the specified JSON map.
|
||||
*/
|
||||
static function fromJson(object $map): self {
|
||||
return new static([
|
||||
'email' => isset($map->email) && is_string($map->email) ? mb_strtolower($map->email) : '',
|
||||
'name' => isset($map->name) && is_string($map->name) ? $map->name : '',
|
||||
'username' => isset($map->username) && is_string($map->username) ? $map->username : ''
|
||||
]);
|
||||
return (new static(isset($map->username) && is_string($map->username) ? $map->username : ''))
|
||||
->setEmail(isset($map->email) && is_string($map->email) ? mb_strtolower($map->email) : '')
|
||||
->setName(isset($map->name) && is_string($map->name) ? $map->name : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mail address.
|
||||
* @return string The mail address.
|
||||
*/
|
||||
function getEmail(): string {
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the full name.
|
||||
* @return string The full name.
|
||||
*/
|
||||
function getName(): string {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the Gitea account.
|
||||
* @return string The name of the Gitea account.
|
||||
*/
|
||||
function getUsername(): string {
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,14 +71,29 @@ class PayloadUser implements \JsonSerializable {
|
||||
*/
|
||||
function jsonSerialize(): \stdClass {
|
||||
return (object) [
|
||||
'after' => $this->getAfter(),
|
||||
'before' => $this->getBefore(),
|
||||
'compare_url' => ($url = $this->getCompareUrl()) ? (string) $url : null,
|
||||
'commits' => array_map(function(PayloadCommit $commit) { return $commit->jsonSerialize(); }, $this->getCommits()->getArrayCopy()),
|
||||
'pusher',
|
||||
'ref' => $this->getRef(),
|
||||
'repository',
|
||||
'sender'
|
||||
'email' => $this->getEmail(),
|
||||
'name' => $this->getName(),
|
||||
'username' => $this->getUsername()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the mail address.
|
||||
* @param string $value The new mail address.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setEmail(string $value): self {
|
||||
$this->email = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the full name.
|
||||
* @param string $value The new full name.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setName(string $value): self {
|
||||
$this->name = $value;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,16 @@ use Psr\Http\Message\{UriInterface};
|
||||
*/
|
||||
class Repository implements \JsonSerializable {
|
||||
|
||||
/**
|
||||
* @var UriInterface|null The HTTP-based URL for cloning this repository.
|
||||
*/
|
||||
private $cloneUrl;
|
||||
|
||||
/**
|
||||
* @var \DateTime|null The date the repository was created.
|
||||
*/
|
||||
private $createdAt;
|
||||
|
||||
/**
|
||||
* @var string The name of the default branch.
|
||||
*/
|
||||
@ -28,17 +38,22 @@ class Repository implements \JsonSerializable {
|
||||
/**
|
||||
* @var string The full name.
|
||||
*/
|
||||
private $fullName = '';
|
||||
private $fullName;
|
||||
|
||||
/**
|
||||
* @var UriInterface|null The Gitea URL of this repository.
|
||||
*/
|
||||
private $htmlUrl;
|
||||
|
||||
/**
|
||||
* @var int The repository identifier.
|
||||
*/
|
||||
private $id = -1;
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var bool Value indicating whether this repository is empty.
|
||||
*/
|
||||
private $isEmpty = false;
|
||||
private $isEmpty = true;
|
||||
|
||||
/**
|
||||
* @var bool Value indicating whether this repository is a fork.
|
||||
@ -85,77 +100,69 @@ class Repository implements \JsonSerializable {
|
||||
*/
|
||||
private $size = 0;
|
||||
|
||||
/**
|
||||
* @var int The number of stars of this repository.
|
||||
*/
|
||||
private $starsCount = 0;
|
||||
|
||||
/**
|
||||
* @var int The number of watchers of this repository.
|
||||
*/
|
||||
private $watchersCount = 0;
|
||||
|
||||
/**
|
||||
* @var UriInterface|null The HTTP-based URL for cloning this repository.
|
||||
*/
|
||||
private $cloneUrl;
|
||||
|
||||
/**
|
||||
* @var \DateTime|null The date the repository was created.
|
||||
*/
|
||||
private $createdAt;
|
||||
|
||||
/**
|
||||
* @var UriInterface|null The Gitea URL of this repository.
|
||||
*/
|
||||
private $htmlUrl;
|
||||
|
||||
/**
|
||||
* @var UriInterface|null The SSH-based URL for cloning this repository.
|
||||
*/
|
||||
private $sshUrl;
|
||||
|
||||
/**
|
||||
* @var int The number of stars of this repository.
|
||||
*/
|
||||
private $starsCount = 0;
|
||||
|
||||
/**
|
||||
* @var \DateTime|null The date the repository was updated.
|
||||
*/
|
||||
private $updatedAt;
|
||||
|
||||
/**
|
||||
* @var int The number of watchers of this repository.
|
||||
*/
|
||||
private $watchersCount = 0;
|
||||
|
||||
/**
|
||||
* @var UriInterface|null The URL of the repository website.
|
||||
*/
|
||||
private $website;
|
||||
|
||||
/**
|
||||
* Creates a new repository.
|
||||
* @param int $id The repository identifier.
|
||||
* @param string $fullName The full name of the repository.
|
||||
*/
|
||||
function __construct(int $id, string $fullName) {
|
||||
$this->id = $id;
|
||||
$this->setFullName($fullName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new repository from the specified JSON map.
|
||||
* @param object $map A JSON map representing a repository.
|
||||
* @return static The instance corresponding to the specified JSON map.
|
||||
*/
|
||||
static function fromJson(object $map): self {
|
||||
return new static([
|
||||
'cloneUrl' => isset($map->clone_url) && is_string($map->clone_url) ? new Uri($map->clone_url) : null,
|
||||
'createdAt' => isset($map->created_at) && is_string($map->created_at) ? new \DateTime($map->created_at) : null,
|
||||
'defaultBranch' => isset($map->default_branch) && is_string($map->default_branch) ? $map->default_branch : '',
|
||||
'description' => isset($map->description) && is_string($map->description) ? $map->description : '',
|
||||
'forksCount' => isset($map->forks_count) && is_int($map->forks_count) ? $map->forks_count : 0,
|
||||
'fullName' => isset($map->full_name) && is_string($map->full_name) ? $map->full_name : '',
|
||||
'htmlUrl' => isset($map->html_url) && is_string($map->html_url) ? new Uri($map->html_url) : null,
|
||||
'id' => isset($map->id) && is_int($map->id) ? $map->id : -1,
|
||||
'isEmpty' => isset($map->empty) && is_bool($map->empty) ? $map->empty : false,
|
||||
'isFork' => isset($map->fork) && is_bool($map->fork) ? $map->fork : false,
|
||||
'isMirror' => isset($map->mirror) && is_bool($map->mirror) ? $map->mirror : false,
|
||||
'isPrivate' => isset($map->private) && is_bool($map->private) ? $map->private : false,
|
||||
'name' => isset($map->name) && is_string($map->name) ? $map->name : '',
|
||||
'openIssuesCount' => isset($map->open_issues_count) && is_int($map->open_issues_count) ? $map->open_issues_count : 0,
|
||||
'owner' => isset($map->owner) && is_object($map->owner) ? User::fromJson($map->owner) : null,
|
||||
'parent' => isset($map->parent) && is_object($map->parent) ? Repository::fromJson($map->parent) : null,
|
||||
'permissions' => isset($map->permissions) && is_object($map->permissions) ? Permission::fromJson($map->permissions) : null,
|
||||
'size' => isset($map->size) && is_int($map->size) ? $map->size : 0,
|
||||
'sshUrl' => isset($map->ssh_url) && is_string($map->ssh_url) ? new Uri($map->ssh_url) : null,
|
||||
'starsCount' => isset($map->stars_count) && is_int($map->stars_count) ? $map->stars_count : 0,
|
||||
'updatedAt' => isset($map->updated_at) && is_string($map->updated_at) ? new \DateTime($map->updated_at) : null,
|
||||
'watchersCount' => isset($map->watchers_count) && is_int($map->watchers_count) ? $map->watchers_count : 0,
|
||||
'website' => isset($map->website) && is_string($map->website) ? new Uri($map->website) : null,
|
||||
]);
|
||||
return (new static(isset($map->id) && is_int($map->id) ? $map->id : -1, isset($map->full_name) && is_string($map->full_name) ? $map->full_name : ''))
|
||||
->setCloneUrl(isset($map->clone_url) && is_string($map->clone_url) ? new Uri($map->clone_url) : null)
|
||||
->setCreatedAt(isset($map->created_at) && is_string($map->created_at) ? new \DateTime($map->created_at) : null)
|
||||
->setDefaultBranch(isset($map->default_branch) && is_string($map->default_branch) ? $map->default_branch : '')
|
||||
->setDescription(isset($map->description) && is_string($map->description) ? $map->description : '')
|
||||
->setEmpty(isset($map->empty) && is_bool($map->empty) ? $map->empty : true)
|
||||
->setFork(isset($map->fork) && is_bool($map->fork) ? $map->fork : false)
|
||||
->setForksCount(isset($map->forks_count) && is_int($map->forks_count) ? $map->forks_count : 0)
|
||||
->setHtmlUrl(isset($map->html_url) && is_string($map->html_url) ? new Uri($map->html_url) : null)
|
||||
->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) ? User::fromJson($map->owner) : null)
|
||||
->setParent(isset($map->parent) && is_object($map->parent) ? Repository::fromJson($map->parent) : null)
|
||||
->setPermissions(isset($map->permissions) && is_object($map->permissions) ? Permission::fromJson($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)
|
||||
->setStarsCount(isset($map->stars_count) && is_int($map->stars_count) ? $map->stars_count : 0)
|
||||
->setUpdatedAt(isset($map->updated_at) && is_string($map->updated_at) ? new \DateTime($map->updated_at) : null)
|
||||
->setWatchersCount(isset($map->watchers_count) && is_int($map->watchers_count) ? $map->watchers_count : 0)
|
||||
->setWebsite(isset($map->website) && is_string($map->website) ? new Uri($map->website) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -174,6 +181,38 @@ class Repository implements \JsonSerializable {
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the default branch.
|
||||
* @return string The name of the default branch.
|
||||
*/
|
||||
function getDefaultBranch(): string {
|
||||
return $this->defaultBranch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the repository description.
|
||||
* @return string The repository description.
|
||||
*/
|
||||
function getDescription(): string {
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of forks of this repository.
|
||||
* @return int The number of forks of this repository.
|
||||
*/
|
||||
function getForksCount(): int {
|
||||
return $this->forksCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the full name.
|
||||
* @return string The full name.
|
||||
*/
|
||||
function getFullName(): string {
|
||||
return $this->fullName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Gitea URL of this repository.
|
||||
* @return UriInterface|null The Gitea URL of this repository.
|
||||
@ -182,6 +221,63 @@ class Repository implements \JsonSerializable {
|
||||
return $this->htmlUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the repository identifier.
|
||||
* @return int The repository identifier.
|
||||
*/
|
||||
function getId(): int {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the repository name.
|
||||
* @return string The repository name.
|
||||
*/
|
||||
function getName(): string {
|
||||
if (mb_strlen($this->name)) return $this->name;
|
||||
return mb_strlen($fullName = $this->getFullName()) ? explode('/', $fullName, 2)[0] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of open issues of this repository.
|
||||
* @return int The number of open issues of this repository.
|
||||
*/
|
||||
function getOpenIssuesCount(): int {
|
||||
return $this->openIssuesCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the repository owner.
|
||||
* @return User|null The repository owner.
|
||||
*/
|
||||
function getOwner(): ?User {
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parent repository, if this repository is a fork or a mirror.
|
||||
* @return User|null The parent repository, if this repository is a fork or a mirror.
|
||||
*/
|
||||
function getParent(): ?Repository {
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the repository permissions.
|
||||
* @return Permission|null The repository permissions.
|
||||
*/
|
||||
function getPermissions(): ?Permission {
|
||||
return $this->permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the repository size, in kilobytes.
|
||||
* @return int The repository size, in kilobytes.
|
||||
*/
|
||||
function getSize(): int {
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the SSH-based URL for cloning this repository.
|
||||
* @return UriInterface|null The SSH-based URL for cloning this repository.
|
||||
@ -190,6 +286,14 @@ class Repository implements \JsonSerializable {
|
||||
return $this->sshUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of stars of this repository.
|
||||
* @return int The number of stars of this repository.
|
||||
*/
|
||||
function getStarsCount(): int {
|
||||
return $this->starsCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the date the repository was updated.
|
||||
* @return \DateTime|null The date the repository was updated.
|
||||
@ -198,6 +302,14 @@ class Repository implements \JsonSerializable {
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of watchers of this repository.
|
||||
* @return int The number of watchers of this repository.
|
||||
*/
|
||||
function getWatchersCount(): int {
|
||||
return $this->watchersCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the URL of the repository website.
|
||||
* @return UriInterface|null The URL of the repository website.
|
||||
@ -206,6 +318,38 @@ class Repository implements \JsonSerializable {
|
||||
return $this->website;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a value indicating whether this repository is empty.
|
||||
* @return bool `true` if this repository is empty, otherwise `false`.
|
||||
*/
|
||||
function isEmpty(): bool {
|
||||
return $this->isEmpty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a value indicating whether this repository is a fork.
|
||||
* @return bool `true` if this repository is a fork, otherwise `false`.
|
||||
*/
|
||||
function isFork(): bool {
|
||||
return $this->isFork;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a value indicating whether this repository is a mirror.
|
||||
* @return bool `true` if this repository is a mirror, otherwise `false`.
|
||||
*/
|
||||
function isMirror(): bool {
|
||||
return $this->isMirror;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a value indicating whether this repository is private.
|
||||
* @return bool `true` if this repository is private, otherwise `false`.
|
||||
*/
|
||||
function isPrivate(): bool {
|
||||
return $this->isPrivate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this object to a map in JSON format.
|
||||
* @return \stdClass The map in JSON format corresponding to this object.
|
||||
@ -258,6 +402,66 @@ class Repository implements \JsonSerializable {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the default branch.
|
||||
* @param string $value The new default branch.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setDefaultBranch(string $value): self {
|
||||
$this->defaultBranch = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the repository description.
|
||||
* @param string $value The new repository description.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setDescription(string $value): self {
|
||||
$this->description = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value indicating whether this repository is empty.
|
||||
* @param bool $value `true` if this repository is empty, otherwise `false`.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setEmpty(bool $value): self {
|
||||
$this->isEmpty = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value indicating whether this repository is a fork.
|
||||
* @param bool $value `true` if this repository is a fork, otherwise `false`.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setFork(bool $value): self {
|
||||
$this->isFork = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of forks of this repository.
|
||||
* @param int $value The new number of forks.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setForksCount(int $value): self {
|
||||
$this->forksCount = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the full name.
|
||||
* @param string $value The new full name.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setFullName(string $value): self {
|
||||
$this->fullName = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Gitea URL of this repository.
|
||||
* @param UriInterface|string|null $value The new Gitea URL.
|
||||
@ -268,6 +472,86 @@ class Repository implements \JsonSerializable {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value indicating whether this repository is a mirror.
|
||||
* @param bool $value `true` if this repository is a mirror, otherwise `false`.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setMirror(bool $value): self {
|
||||
$this->isMirror = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the repository name.
|
||||
* @param string $value The new repository name.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setName(string $value): self {
|
||||
$this->name = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of open issues of this repository.
|
||||
* @param int $value The new number of open issues.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setOpenIssuesCount(int $value): self {
|
||||
$this->openIssuesCount = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the repository owner.
|
||||
* @param User|null $value The new owner.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setOwner(?User $value): self {
|
||||
$this->owner = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parent repository, if this repository is a fork or a mirror.
|
||||
* @param Repository|null $value The new parent repository.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setParent(?Repository $value): self {
|
||||
$this->parent = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the repository permissions.
|
||||
* @param Permission|null $value The new permissions.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setPermissions(?Permission $value): self {
|
||||
$this->permissions = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value indicating whether this repository is private.
|
||||
* @param bool $value `true` if this repository is private, otherwise `false`.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setPrivate(bool $value): self {
|
||||
$this->isPrivate = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the repository size, in kilobytes.
|
||||
* @param int $value The new repository size, in kilobytes.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setSize(int $value): self {
|
||||
$this->size = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the SSH-based URL for cloning this repository.
|
||||
* @param UriInterface|string|null $value The new URL for cloning this repository.
|
||||
@ -278,6 +562,16 @@ class Repository implements \JsonSerializable {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of stars of this repository.
|
||||
* @param int $value The new number of stars.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setStarsCount(int $value): self {
|
||||
$this->starsCount = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the date the repository was updated.
|
||||
* @param \DateTime|string|null $value The new date of update.
|
||||
@ -288,6 +582,16 @@ class Repository implements \JsonSerializable {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of watchers of this repository.
|
||||
* @param int $value The new number of watchers.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setWatchersCount(int $value): self {
|
||||
$this->watchersCount = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the URL of the repository website.
|
||||
* @param UriInterface|string|null $value The new repository website.
|
||||
|
||||
@ -32,7 +32,7 @@ class Team implements \JsonSerializable {
|
||||
* @param int $id The team identifier.
|
||||
* @param string $name The team name.
|
||||
*/
|
||||
function __construct(int $id, string $name = '') {
|
||||
function __construct(int $id, string $name) {
|
||||
$this->id = $id;
|
||||
$this->setName($name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user