Corrected namespaces + Chnaged tab size to 4

+ Went through all the Model classes and updated their namespaces to match their parent folder name
+ Changed tab sizes to 4 spaces instead of 2 (in all php files)
This commit is contained in:
Benjamin Blake
2020-02-20 13:21:18 -07:00
parent b17224ce39
commit dcd2d8bdf3
15 changed files with 1679 additions and 1712 deletions

View File

@ -5,7 +5,7 @@ namespace Gitea\Api;
use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Response;
use Gitea\Client; use Gitea\Client;
use Gitea\Models\Organization; use Gitea\Model\Organization;
use Gitea\Api\Abstracts\AbstractApi; use Gitea\Api\Abstracts\AbstractApi;

View File

@ -6,7 +6,7 @@ use GuzzleHttp\Exception\ServerException;
use Gitea\Client; use Gitea\Client;
use Gitea\Collections\ApiItemCollection; use Gitea\Collections\ApiItemCollection;
use Gitea\Models\Repository; use Gitea\Model\Repository;
use Gitea\Api\Abstracts\AbstractAllApi; use Gitea\Api\Abstracts\AbstractAllApi;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Gitea\Models; namespace Gitea\Model;
use GuzzleHttp\Psr7\Uri; use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\UriInterface; use Psr\Http\Message\UriInterface;
@ -10,140 +10,140 @@ use \JsonSerializable;
/** Represents a Gitea organization. */ /** Represents a Gitea organization. */
class Organization implements JsonSerializable { class Organization implements JsonSerializable {
/** @var UriInterface|null A URL pointing to the organization's avatar. */ /** @var UriInterface|null A URL pointing to the organization's avatar. */
private $avatarURL = ''; private $avatarURL = '';
/** @var string The organization description. */ /** @var string The organization description. */
private $description = ''; private $description = '';
/** @var string The organization's full name. */ /** @var string The organization's full name. */
private $fullName = ''; private $fullName = '';
/** @var int The organization identifier. */ /** @var int The organization identifier. */
private $id = -1; private $id = -1;
/** @var string The organization location. */ /** @var string The organization location. */
private $location; private $location;
/** @var string The username of the organization */ /** @var string The username of the organization */
private $username; private $username;
/** @var string The visibility of the organization */ /** @var string The visibility of the organization */
private $visibility; private $visibility;
/** @var UriInterface|null The website URL of the organization */ /** @var UriInterface|null The website URL of the organization */
private $website = null; private $website = null;
/** /**
* Creates a new organization. * Creates a new organization.
* @param string $username The organization name. * @param string $username The organization name.
* @param string $visibility The organization visibility. * @param string $visibility The organization visibility.
*/ */
function __construct(string $username, string $visibility = "private") { function __construct(string $username, string $visibility = "private") {
$this->setUserName($username); $this->setUserName($username);
$this->setVisibility($visibility); $this->setVisibility($visibility);
} }
/** /**
* Creates a new organization from the specified JSON map. * Creates a new organization from the specified JSON map.
* @param object $map A JSON map representing an organization. * @param object $map A JSON map representing an organization.
* @return static The instance corresponding to the specified JSON map. * @return static The instance corresponding to the specified JSON map.
*/ */
static function fromJson(object $map): self { static function fromJson(object $map): self {
return (new static(isset($map->username) && is_string($map->username) ? $map->username : '', isset($map->visibility) && is_string($map->visibility) ? $map->visibility : 'private')) return (new static(isset($map->username) && is_string($map->username) ? $map->username : '', isset($map->visibility) && is_string($map->visibility) ? $map->visibility : 'private'))
->setAvatarURL(isset($map->avatar_url) && is_string($map->avatar_url) ? new Uri($map->avatar_url) : null) ->setAvatarURL(isset($map->avatar_url) && is_string($map->avatar_url) ? new Uri($map->avatar_url) : null)
->setDescription(isset($map->description) && is_string($map->description) ? $map->description : '') ->setDescription(isset($map->description) && is_string($map->description) ? $map->description : '')
->setFullName(isset($map->full_name) && is_string($map->full_name) ? $map->full_name : '') ->setFullName(isset($map->full_name) && is_string($map->full_name) ? $map->full_name : '')
->setLocation(isset($map->location) && is_string($map->location) ? $map->location : '') ->setLocation(isset($map->location) && is_string($map->location) ? $map->location : '')
->setWebsite(isset($map->website) && is_string($map->website) ? new Uri($map->website) : null); ->setWebsite(isset($map->website) && is_string($map->website) ? new Uri($map->website) : null);
} }
/** /**
* Converts this object to a map in JSON format. * Converts this object to a map in JSON format.
* @return \stdClass The map in JSON format corresponding to this object. * @return \stdClass The map in JSON format corresponding to this object.
*/ */
function jsonSerialize(): \stdClass { function jsonSerialize(): \stdClass {
return (object) [ return (object) [
'avatar_url' => ($url = $this->getAvatarURL()) ? (string) $url : null, 'avatar_url' => ($url = $this->getAvatarURL()) ? (string) $url : null,
'description' => $this->getDescription(), 'description' => $this->getDescription(),
'full_name' => $this->getFullName(), 'full_name' => $this->getFullName(),
'id' => $this->getId(), 'id' => $this->getId(),
'location' => $this->getLocation(), 'location' => $this->getLocation(),
'username' => $this->getUsername(), 'username' => $this->getUsername(),
'visibility' => $this->getVisibility(), 'visibility' => $this->getVisibility(),
'website' => ($url = $this->getWebsite()) ? (string) $url : null 'website' => ($url = $this->getWebsite()) ? (string) $url : null
]; ];
} }
/** /**
* Gets the organization identifier. * Gets the organization identifier.
* @return int The organization identifier. * @return int The organization identifier.
*/ */
function getId(): int { function getId(): int {
return $this->id; return $this->id;
} }
public function getAvatarURL(): ?UriInterface { public function getAvatarURL(): ?UriInterface {
return $this->avatarURL; return $this->avatarURL;
} }
public function setAvatarURL(?UriInterface $value): self { public function setAvatarURL(?UriInterface $value): self {
$this->avatarURL = $value; $this->avatarURL = $value;
return $this; return $this;
} }
public function getDescription() { public function getDescription() {
return $this->description; return $this->description;
} }
public function setDescription(string $value): self { public function setDescription(string $value): self {
$this->description = $value; $this->description = $value;
return $this; return $this;
} }
public function getFullName() { public function getFullName() {
return $this->fullName; return $this->fullName;
} }
public function setFullName(string $value): self { public function setFullName(string $value): self {
$this->fullName = $value; $this->fullName = $value;
return $this; return $this;
} }
public function getLocation() { public function getLocation() {
return $this->location; return $this->location;
} }
public function setLocation(string $value): self { public function setLocation(string $value): self {
$this->location = $value; $this->location = $value;
return $this; return $this;
} }
public function getUsername() { public function getUsername() {
return $this->username; return $this->username;
} }
public function setUsername(string $value): self { public function setUsername(string $value): self {
$this->username = $value; $this->username = $value;
return $this; return $this;
} }
public function getVisibility() { public function getVisibility() {
return $this->visibility; return $this->visibility;
} }
public function setVisibility(string $value): self { public function setVisibility(string $value): self {
$this->visibility = $value; $this->visibility = $value;
return $this; return $this;
} }
public function getWebsite(): ?UriInterface { public function getWebsite(): ?UriInterface {
return $this->website; return $this->website;
} }
public function setWebsite(?UriInterface $value): self { public function setWebsite(?UriInterface $value): self {
$this->website = $value; $this->website = $value;
return $this; return $this;
} }
} }

View File

@ -1,5 +1,5 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace Gitea\Models; namespace Gitea\Model;
use GuzzleHttp\Psr7\{Uri}; use GuzzleHttp\Psr7\{Uri};
use Psr\Http\Message\{UriInterface}; use Psr\Http\Message\{UriInterface};
@ -7,180 +7,180 @@ use Psr\Http\Message\{UriInterface};
/** Represents a commit. */ /** Represents a commit. */
class PayloadCommit implements \JsonSerializable { class PayloadCommit implements \JsonSerializable {
/** @var PayloadUser|null The person who authored the commit. */ /** @var PayloadUser|null The person who authored the commit. */
private $author; private $author;
/** @var PayloadUser|null The person who committed the code. */ /** @var PayloadUser|null The person who committed the code. */
private $committer; private $committer;
/** @var string The commit hash. */ /** @var string The commit hash. */
private $id; private $id;
/** @var string The commit message. */ /** @var string The commit message. */
private $message; private $message;
/** @var \DateTime|null The commit date. */ /** @var \DateTime|null The commit date. */
private $timestamp; private $timestamp;
/** @var UriInterface|null The URL to the commit's history. */ /** @var UriInterface|null The URL to the commit's history. */
private $url; private $url;
/** @var PayloadCommitVerification|null The GPG verification of this commit. */ /** @var PayloadCommitVerification|null The GPG verification of this commit. */
private $verification; private $verification;
/** /**
* Creates a new payload commit. * Creates a new payload commit.
* @param string $id The commit hash. * @param string $id The commit hash.
* @param string $message The commit message. * @param string $message The commit message.
*/ */
function __construct(string $id, string $message) { function __construct(string $id, string $message) {
$this->id = $id; $this->id = $id;
$this->setMessage($message); $this->setMessage($message);
} }
/** /**
* Creates a new commit from the specified JSON map. * Creates a new commit from the specified JSON map.
* @param object $map A JSON map representing a commit. * @param object $map A JSON map representing a commit.
* @return static The instance corresponding to the specified JSON map. * @return static The instance corresponding to the specified JSON map.
*/ */
static function fromJson(object $map): self { static function fromJson(object $map): self {
return (new static(isset($map->id) && is_string($map->id) ? $map->id : '', isset($map->message) && is_string($map->message) ? $map->message : '')) return (new static(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($map->author) : null) ->setAuthor(isset($map->author) && is_object($map->author) ? PayloadUser::fromJson($map->author) : null)
->setCommitter(isset($map->committer) && is_object($map->committer) ? PayloadUser::fromJson($map->committer) : null) ->setCommitter(isset($map->committer) && is_object($map->committer) ? PayloadUser::fromJson($map->committer) : null)
->setTimestamp(isset($map->timestamp) && is_string($map->timestamp) ? new \DateTime($map->timestamp) : 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) ->setUrl(isset($map->url) && is_string($map->url) ? new Uri($map->url) : null)
->setVerification(isset($map->verification) && is_object($map->verification) ? PayloadCommitVerification::fromJson($map->verification) : null); ->setVerification(isset($map->verification) && is_object($map->verification) ? PayloadCommitVerification::fromJson($map->verification) : null);
} }
/** /**
* Gets the person who authored the commit. * Gets the person who authored the commit.
* @return PayloadUser|null The person who authored the commit. * @return PayloadUser|null The person who authored the commit.
*/ */
function getAuthor(): ?PayloadUser { function getAuthor(): ?PayloadUser {
return $this->author; return $this->author;
} }
/** /**
* Gets the person who committed the code. * Gets the person who committed the code.
* @return PayloadUser|null The person who committed the code. * @return PayloadUser|null The person who committed the code.
*/ */
function getCommitter(): ?PayloadUser { function getCommitter(): ?PayloadUser {
return $this->committer; return $this->committer;
} }
/** /**
* Gets the commit hash. * Gets the commit hash.
* @return string The commit hash. * @return string The commit hash.
*/ */
function getId(): string { function getId(): string {
return $this->id; return $this->id;
} }
/** /**
* Gets the commit message. * Gets the commit message.
* @return string The commit message. * @return string The commit message.
*/ */
function getMessage(): string { function getMessage(): string {
return $this->message; return $this->message;
} }
/** /**
* Gets the commit date. * Gets the commit date.
* @return \DateTime|null The commit date. * @return \DateTime|null The commit date.
*/ */
function getTimestamp(): ?\DateTime { function getTimestamp(): ?\DateTime {
return $this->timestamp; return $this->timestamp;
} }
/** /**
* Gets the URL to the commit's history. * Gets the URL to the commit's history.
* @return UriInterface|null The URL to the commit's history. * @return UriInterface|null The URL to the commit's history.
*/ */
function getUrl(): ?UriInterface { function getUrl(): ?UriInterface {
return $this->url; return $this->url;
} }
/** /**
* Gets the GPG verification of this commit. * Gets the GPG verification of this commit.
* @return PayloadCommitVerification|null The GPG verification of this commit. * @return PayloadCommitVerification|null The GPG verification of this commit.
*/ */
function getVerification(): ?PayloadCommitVerification { function getVerification(): ?PayloadCommitVerification {
return $this->verification; return $this->verification;
} }
/** /**
* Converts this object to a map in JSON format. * Converts this object to a map in JSON format.
* @return \stdClass The map in JSON format corresponding to this object. * @return \stdClass The map in JSON format corresponding to this object.
*/ */
function jsonSerialize(): \stdClass { function jsonSerialize(): \stdClass {
return (object) [ return (object) [
'author' => ($author = $this->getAuthor()) ? $author->jsonSerialize() : null, 'author' => ($author = $this->getAuthor()) ? $author->jsonSerialize() : null,
'committer' => ($committer = $this->getCommitter()) ? $committer->jsonSerialize() : null, 'committer' => ($committer = $this->getCommitter()) ? $committer->jsonSerialize() : null,
'id' => $this->getId(), 'id' => $this->getId(),
'message' => $this->getMessage(), 'message' => $this->getMessage(),
'timestamp' => ($date = $this->getTimestamp()) ? $date->format('c') : null, 'timestamp' => ($date = $this->getTimestamp()) ? $date->format('c') : null,
'url' => ($url = $this->getUrl()) ? (string) $url : null, 'url' => ($url = $this->getUrl()) ? (string) $url : null,
'verification' => ($verification = $this->getVerification()) ? $verification->jsonSerialize() : null 'verification' => ($verification = $this->getVerification()) ? $verification->jsonSerialize() : null
]; ];
} }
/** /**
* Sets the person who authored the commit. * Sets the person who authored the commit.
* @param PayloadUser|null $value The new author. * @param PayloadUser|null $value The new author.
* @return $this This instance. * @return $this This instance.
*/ */
function setAuthor(?PayloadUser $value): self { function setAuthor(?PayloadUser $value): self {
$this->author = $value; $this->author = $value;
return $this; return $this;
} }
/** /**
* Sets the person who committed the code. * Sets the person who committed the code.
* @param PayloadUser|null $value The new committer. * @param PayloadUser|null $value The new committer.
* @return $this This instance. * @return $this This instance.
*/ */
function setCommitter(?PayloadUser $value): self { function setCommitter(?PayloadUser $value): self {
$this->committer = $value; $this->committer = $value;
return $this; return $this;
} }
/** /**
* Sets the commit message. * Sets the commit message.
* @param string $value The new message. * @param string $value The new message.
* @return $this This instance. * @return $this This instance.
*/ */
function setMessage(string $value): self { function setMessage(string $value): self {
$this->message = $value; $this->message = $value;
return $this; return $this;
} }
/** /**
* Sets the commit date. * Sets the commit date.
* @param \DateTime|null $value The new commit date. * @param \DateTime|null $value The new commit date.
* @return $this This instance. * @return $this This instance.
*/ */
function setTimestamp(?\DateTime $value): self { function setTimestamp(?\DateTime $value): self {
$this->timestamp = $value; $this->timestamp = $value;
return $this; return $this;
} }
/** /**
* Sets the URL to the commit's history. * Sets the URL to the commit's history.
* @param UriInterface|null $value The new commit URL. * @param UriInterface|null $value The new commit URL.
* @return $this This instance. * @return $this This instance.
*/ */
function setUrl(?UriInterface $value): self { function setUrl(?UriInterface $value): self {
$this->url = $value; $this->url = $value;
return $this; return $this;
} }
/** /**
* Sets the commit message. * Sets the commit message.
* @param PayloadCommitVerification|null $value The new message. * @param PayloadCommitVerification|null $value The new message.
* @return $this This instance. * @return $this This instance.
*/ */
function setVerification(?PayloadCommitVerification $value): self { function setVerification(?PayloadCommitVerification $value): self {
$this->verification = $value; $this->verification = $value;
return $this; return $this;
} }
} }

View File

@ -1,123 +1,123 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace Gitea\Models; namespace Gitea\Model;
/** Represents the GPG verification of a commit. */ /** Represents the GPG verification of a commit. */
class PayloadCommitVerification implements \JsonSerializable { class PayloadCommitVerification implements \JsonSerializable {
/** @var bool Value indicating whether the verification has succeeded. */ /** @var bool Value indicating whether the verification has succeeded. */
private $isVerified; private $isVerified;
/** @var string A custom message sent with the verification request. */ /** @var string A custom message sent with the verification request. */
private $payload = ''; private $payload = '';
/** @var string A message providing details about the verification. */ /** @var string A message providing details about the verification. */
private $reason = ''; private $reason = '';
/** @var string The signing key used for the verification. */ /** @var string The signing key used for the verification. */
private $signature = ''; private $signature = '';
/** /**
* Creates a new verification of a payload commit. * Creates a new verification of a payload commit.
* @param bool $isVerified Value indicating whether the verification has succeeded. * @param bool $isVerified Value indicating whether the verification has succeeded.
*/ */
function __construct(bool $isVerified = false) { function __construct(bool $isVerified = false) {
$this->setVerified($isVerified); $this->setVerified($isVerified);
} }
/** /**
* Creates a new commit from the specified JSON map. * Creates a new commit from the specified JSON map.
* @param object $map A JSON map representing a commit. * @param object $map A JSON map representing a commit.
* @return static The instance corresponding to the specified JSON map. * @return static The instance corresponding to the specified JSON map.
*/ */
static function fromJson(object $map): self { static function fromJson(object $map): self {
return (new static(isset($map->verified) && is_bool($map->verified) ? $map->verified : false)) return (new static(isset($map->verified) && is_bool($map->verified) ? $map->verified : false))
->setPayload(isset($map->payload) && is_string($map->payload) ? $map->payload : '') ->setPayload(isset($map->payload) && is_string($map->payload) ? $map->payload : '')
->setReason(isset($map->reason) && is_string($map->reason) ? $map->reason : '') ->setReason(isset($map->reason) && is_string($map->reason) ? $map->reason : '')
->setSignature(isset($map->signature) && is_string($map->signature) ? $map->signature : ''); ->setSignature(isset($map->signature) && is_string($map->signature) ? $map->signature : '');
} }
/** /**
* Gets the custom message sent with the verification request. * Gets the custom message sent with the verification request.
* @return string The custom message sent with the verification request. * @return string The custom message sent with the verification request.
*/ */
function getPayload(): string { function getPayload(): string {
return $this->payload; return $this->payload;
} }
/** /**
* Gets the message providing details about the verification. * Gets the message providing details about the verification.
* @return string The message providing details about the verification. * @return string The message providing details about the verification.
*/ */
function getReason(): string { function getReason(): string {
return $this->reason; return $this->reason;
} }
/** /**
* Gets the signing key used for the verification. * Gets the signing key used for the verification.
* @return string The signing key used for the verification. * @return string The signing key used for the verification.
*/ */
function getSignature(): string { function getSignature(): string {
return $this->signature; return $this->signature;
} }
/** /**
* Gets a value indicating whether the verification has succeeded. * Gets a value indicating whether the verification has succeeded.
* @return bool `true` if the verification has succeeded, otherwise `false`. * @return bool `true` if the verification has succeeded, otherwise `false`.
*/ */
function isVerified(): bool { function isVerified(): bool {
return $this->isVerified; return $this->isVerified;
} }
/** /**
* Converts this object to a map in JSON format. * Converts this object to a map in JSON format.
* @return \stdClass The map in JSON format corresponding to this object. * @return \stdClass The map in JSON format corresponding to this object.
*/ */
function jsonSerialize(): \stdClass { function jsonSerialize(): \stdClass {
return (object) [ return (object) [
'payload' => $this->getPayload(), 'payload' => $this->getPayload(),
'reason' => $this->getReason(), 'reason' => $this->getReason(),
'signature' => $this->getSignature(), 'signature' => $this->getSignature(),
'verified' => $this->isVerified() 'verified' => $this->isVerified()
]; ];
} }
/** /**
* Sets the custom message sent with the verification request. * Sets the custom message sent with the verification request.
* @param string $value A new custom message. * @param string $value A new custom message.
* @return $this This instance. * @return $this This instance.
*/ */
function setPayload(string $value): self { function setPayload(string $value): self {
$this->payload = $value; $this->payload = $value;
return $this; return $this;
} }
/** /**
* Sets the message providing details about the verification. * Sets the message providing details about the verification.
* @param string $value A new message providing details about the verification. * @param string $value A new message providing details about the verification.
* @return $this This instance. * @return $this This instance.
*/ */
function setReason(string $value): self { function setReason(string $value): self {
$this->reason = $value; $this->reason = $value;
return $this; return $this;
} }
/** /**
* Sets the signing key used for the verification. * Sets the signing key used for the verification.
* @param string $value The new signing key. * @param string $value The new signing key.
* @return $this This instance. * @return $this This instance.
*/ */
function setSignature(string $value): self { function setSignature(string $value): self {
$this->signature = $value; $this->signature = $value;
return $this; return $this;
} }
/** /**
* Sets a value indicating whether the verification has succeeded. * Sets a value indicating whether the verification has succeeded.
* @param bool $value `true` if the verification has succeeded, otherwise `false`. * @param bool $value `true` if the verification has succeeded, otherwise `false`.
* @return $this This instance. * @return $this This instance.
*/ */
function setVerified(bool $value): self { function setVerified(bool $value): self {
$this->isVerified = $value; $this->isVerified = $value;
return $this; return $this;
} }
} }

View File

@ -1,90 +1,90 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace Gitea\Models; namespace Gitea\Model;
/** Represents the author or committer of a commit. */ /** Represents the author or committer of a commit. */
class PayloadUser implements \JsonSerializable { class PayloadUser implements \JsonSerializable {
/** @var string The mail address. */ /** @var string The mail address. */
private $email = ''; private $email = '';
/** @var string The full name. */ /** @var string The full name. */
private $name = ''; private $name = '';
/** @var string The name of the Gitea account. */ /** @var string The name of the Gitea account. */
private $username; private $username;
/** /**
* Creates a new payload user. * Creates a new payload user.
* @param string $username The name of the Gitea account. * @param string $username The name of the Gitea account.
*/ */
function __construct(string $username) { function __construct(string $username) {
$this->username = $username; $this->username = $username;
} }
/** /**
* Creates a new user from the specified JSON map. * Creates a new user from the specified JSON map.
* @param object $map A JSON map representing a user. * @param object $map A JSON map representing a user.
* @return static The instance corresponding to the specified JSON map. * @return static The instance corresponding to the specified JSON map.
*/ */
static function fromJson(object $map): self { static function fromJson(object $map): self {
return (new static(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) : '') ->setEmail(isset($map->email) && is_string($map->email) ? mb_strtolower($map->email) : '')
->setName(isset($map->name) && is_string($map->name) ? $map->name : ''); ->setName(isset($map->name) && is_string($map->name) ? $map->name : '');
} }
/** /**
* Gets the mail address. * Gets the mail address.
* @return string The mail address. * @return string The mail address.
*/ */
function getEmail(): string { function getEmail(): string {
return $this->email; return $this->email;
} }
/** /**
* Gets the full name. * Gets the full name.
* @return string The full name. * @return string The full name.
*/ */
function getName(): string { function getName(): string {
return $this->name; return $this->name;
} }
/** /**
* Gets the name of the Gitea account. * Gets the name of the Gitea account.
* @return string The name of the Gitea account. * @return string The name of the Gitea account.
*/ */
function getUsername(): string { function getUsername(): string {
return $this->username; return $this->username;
} }
/** /**
* Converts this object to a map in JSON format. * Converts this object to a map in JSON format.
* @return \stdClass The map in JSON format corresponding to this object. * @return \stdClass The map in JSON format corresponding to this object.
*/ */
function jsonSerialize(): \stdClass { function jsonSerialize(): \stdClass {
return (object) [ return (object) [
'email' => $this->getEmail(), 'email' => $this->getEmail(),
'name' => $this->getName(), 'name' => $this->getName(),
'username' => $this->getUsername() 'username' => $this->getUsername()
]; ];
} }
/** /**
* Sets the mail address. * Sets the mail address.
* @param string $value The new mail address. * @param string $value The new mail address.
* @return $this This instance. * @return $this This instance.
*/ */
function setEmail(string $value): self { function setEmail(string $value): self {
$this->email = $value; $this->email = $value;
return $this; return $this;
} }
/** /**
* Sets the full name. * Sets the full name.
* @param string $value The new full name. * @param string $value The new full name.
* @return $this This instance. * @return $this This instance.
*/ */
function setName(string $value): self { function setName(string $value): self {
$this->name = $value; $this->name = $value;
return $this; return $this;
} }
} }

View File

@ -1,104 +1,104 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace Gitea\Models; namespace Gitea\Model;
/** Represents a set of permissions. */ /** Represents a set of permissions. */
class Permission implements \JsonSerializable { class Permission implements \JsonSerializable {
/** @var bool Value indicating whether administrator access is allowed. */ /** @var bool Value indicating whether administrator access is allowed. */
private $admin; private $admin;
/** @var bool Value indicating whether pull is allowed. */ /** @var bool Value indicating whether pull is allowed. */
private $pull; private $pull;
/** @var bool Value indicating whether push is allowed. */ /** @var bool Value indicating whether push is allowed. */
private $push; private $push;
/** /**
* Creates a new permission. * Creates a new permission.
* @param bool $admin Value indicating whether administrator access is allowed. * @param bool $admin Value indicating whether administrator access is allowed.
* @param bool $pull Value indicating whether pull is allowed. * @param bool $pull Value indicating whether pull is allowed.
* @param bool $push Value indicating whether push is allowed. * @param bool $push Value indicating whether push is allowed.
*/ */
function __construct(bool $admin = false, bool $pull = false, bool $push = false) { function __construct(bool $admin = false, bool $pull = false, bool $push = false) {
$this->setAdmin($admin)->setPull($pull)->setPush($push); $this->setAdmin($admin)->setPull($pull)->setPush($push);
} }
/** /**
* Creates a new user from the specified JSON map. * Creates a new user from the specified JSON map.
* @param object $map A JSON map representing a user. * @param object $map A JSON map representing a user.
* @return static The instance corresponding to the specified JSON map. * @return static The instance corresponding to the specified JSON map.
*/ */
static function fromJson(object $map): self { static function fromJson(object $map): self {
return new static( return new static(
isset($map->admin) && is_bool($map->admin) ? $map->admin : false, isset($map->admin) && is_bool($map->admin) ? $map->admin : false,
isset($map->pull) && is_bool($map->pull) ? $map->pull : false, isset($map->pull) && is_bool($map->pull) ? $map->pull : false,
isset($map->push) && is_bool($map->push) ? $map->push : false isset($map->push) && is_bool($map->push) ? $map->push : false
); );
} }
/** /**
* Gets a value indicating whether administrator access is allowed. * Gets a value indicating whether administrator access is allowed.
* @return bool `true` if administrator access is allowed, otherwise `false`. * @return bool `true` if administrator access is allowed, otherwise `false`.
*/ */
function getAdmin(): bool { function getAdmin(): bool {
return $this->admin; return $this->admin;
} }
/** /**
* Gets a value indicating whether pull is allowed. * Gets a value indicating whether pull is allowed.
* @return bool `true` if pull is allowed, otherwise `false`. * @return bool `true` if pull is allowed, otherwise `false`.
*/ */
function getPull(): bool { function getPull(): bool {
return $this->pull; return $this->pull;
} }
/** /**
* Gets a value indicating whether push is allowed. * Gets a value indicating whether push is allowed.
* @return bool `true` if push is allowed, otherwise `false`. * @return bool `true` if push is allowed, otherwise `false`.
*/ */
function getPush(): bool { function getPush(): bool {
return $this->push; return $this->push;
} }
/** /**
* Converts this object to a map in JSON format. * Converts this object to a map in JSON format.
* @return \stdClass The map in JSON format corresponding to this object. * @return \stdClass The map in JSON format corresponding to this object.
*/ */
function jsonSerialize(): \stdClass { function jsonSerialize(): \stdClass {
return (object) [ return (object) [
'admin' => $this->getAdmin(), 'admin' => $this->getAdmin(),
'pull' => $this->getPull(), 'pull' => $this->getPull(),
'push' => $this->getPush() 'push' => $this->getPush()
]; ];
} }
/** /**
* Sets a value indicating whether administrator access is allowed. * Sets a value indicating whether administrator access is allowed.
* @param bool $value `true` to allow administrator access, otherwise `false`. * @param bool $value `true` to allow administrator access, otherwise `false`.
* @return $this This instance. * @return $this This instance.
*/ */
function setAdmin(bool $value): self { function setAdmin(bool $value): self {
$this->admin = $value; $this->admin = $value;
return $this; return $this;
} }
/** /**
* Sets a value indicating whether pull is allowed. * Sets a value indicating whether pull is allowed.
* @param bool $value `true` to allow pull, otherwise `false`. * @param bool $value `true` to allow pull, otherwise `false`.
* @return $this This instance. * @return $this This instance.
*/ */
function setPull(bool $value): self { function setPull(bool $value): self {
$this->pull = $value; $this->pull = $value;
return $this; return $this;
} }
/** /**
* Sets a value indicating whether push is allowed. * Sets a value indicating whether push is allowed.
* @param bool $value `true` to allow push, otherwise `false`. * @param bool $value `true` to allow push, otherwise `false`.
* @return $this This instance. * @return $this This instance.
*/ */
function setPush(bool $value): self { function setPush(bool $value): self {
$this->push = $value; $this->push = $value;
return $this; return $this;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,42 +1,42 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace Gitea\Models; namespace Gitea\Model;
/** Wraps the version of the Gitea server. */ /** Wraps the version of the Gitea server. */
class ServerVersion implements \JsonSerializable { class ServerVersion implements \JsonSerializable {
/** @var string The version number. */ /** @var string The version number. */
private $version; private $version;
/** /**
* Creates a new server version. * Creates a new server version.
* @param string $version The version number. * @param string $version The version number.
*/ */
function __construct(string $version) { function __construct(string $version) {
$this->version = $version; $this->version = $version;
} }
/** /**
* Creates a new server version from the specified JSON map. * Creates a new server version from the specified JSON map.
* @param object $map A JSON map representing a server version. * @param object $map A JSON map representing a server version.
* @return static The instance corresponding to the specified JSON map. * @return static The instance corresponding to the specified JSON map.
*/ */
static function fromJson(object $map): self { static function fromJson(object $map): self {
return new static(isset($map->version) && is_string($map->version) ? $map->version : ''); return new static(isset($map->version) && is_string($map->version) ? $map->version : '');
} }
/** /**
* Gets the version number. * Gets the version number.
* @return string The version number. * @return string The version number.
*/ */
function getVersion(): string { function getVersion(): string {
return $this->version; return $this->version;
} }
/** /**
* Converts this object to a map in JSON format. * Converts this object to a map in JSON format.
* @return \stdClass The map in JSON format corresponding to this object. * @return \stdClass The map in JSON format corresponding to this object.
*/ */
function jsonSerialize(): \stdClass { function jsonSerialize(): \stdClass {
return (object) ['version' => $this->getVersion()]; return (object) ['version' => $this->getVersion()];
} }
} }

View File

@ -1,24 +1,24 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace Gitea\Models; namespace Gitea\Model;
use Enum\{EnumTrait}; use Enum\{EnumTrait};
/** Defines the state of a Gitea status. */ /** Defines the state of a Gitea status. */
final class StatusState { final class StatusState {
use EnumTrait; use EnumTrait;
/** @var string The status is an error. */ /** @var string The status is an error. */
const error = 'error'; const error = 'error';
/** @var string The status is a failure. */ /** @var string The status is a failure. */
const failure = 'failure'; const failure = 'failure';
/** @var string The status is pending. */ /** @var string The status is pending. */
const pending = 'pending'; const pending = 'pending';
/** @var string The status is a success. */ /** @var string The status is a success. */
const success = 'success'; const success = 'success';
/** @var string The status is a warning. */ /** @var string The status is a warning. */
const warning = 'warning'; const warning = 'warning';
} }

View File

@ -1,114 +1,114 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace Gitea\Models; namespace Gitea\Model;
/** Represents a team in an organization. */ /** Represents a team in an organization. */
class Team implements \JsonSerializable { class Team implements \JsonSerializable {
/** @var string The team description. */ /** @var string The team description. */
private $description = ''; private $description = '';
/** @var int The team identifier. */ /** @var int The team identifier. */
private $id; private $id;
/** @var string The team name. */ /** @var string The team name. */
private $name; private $name;
/** @var string The team permission. */ /** @var string The team permission. */
private $permission = TeamPermission::none; private $permission = TeamPermission::none;
/** /**
* Creates a new team. * Creates a new team.
* @param int $id The team identifier. * @param int $id The team identifier.
* @param string $name The team name. * @param string $name The team name.
*/ */
function __construct(int $id, string $name) { function __construct(int $id, string $name) {
$this->id = $id; $this->id = $id;
$this->setName($name); $this->setName($name);
} }
/** /**
* Creates a new user from the specified JSON map. * Creates a new user from the specified JSON map.
* @param object $map A JSON map representing a user. * @param object $map A JSON map representing a user.
* @return static The instance corresponding to the specified JSON map. * @return static The instance corresponding to the specified JSON map.
*/ */
static function fromJson(object $map): self { static function fromJson(object $map): self {
return (new static(isset($map->id) && is_int($map->id) ? $map->id : -1, isset($map->name) && is_string($map->name) ? $map->name : '')) return (new static(isset($map->id) && is_int($map->id) ? $map->id : -1, isset($map->name) && is_string($map->name) ? $map->name : ''))
->setDescription(isset($map->description) && is_string($map->description) ? $map->description : '') ->setDescription(isset($map->description) && is_string($map->description) ? $map->description : '')
->setPermission(isset($map->permission) && is_string($map->permission) ? $map->permission : TeamPermission::none); ->setPermission(isset($map->permission) && is_string($map->permission) ? $map->permission : TeamPermission::none);
} }
/** /**
* Gets the team description. * Gets the team description.
* @return string The team description. * @return string The team description.
*/ */
function getDescription(): string { function getDescription(): string {
return $this->description; return $this->description;
} }
/** /**
* Gets the team identifier. * Gets the team identifier.
* @return int The team identifier. * @return int The team identifier.
*/ */
function getId(): int { function getId(): int {
return $this->id; return $this->id;
} }
/** /**
* Gets the team name. * Gets the team name.
* @return string The team name. * @return string The team name.
*/ */
function getName(): string { function getName(): string {
return $this->name; return $this->name;
} }
/** /**
* Gets the team permission. * Gets the team permission.
* @return string The team permission. * @return string The team permission.
*/ */
function getPermission(): string { function getPermission(): string {
return $this->permission; return $this->permission;
} }
/** /**
* Converts this object to a map in JSON format. * Converts this object to a map in JSON format.
* @return \stdClass The map in JSON format corresponding to this object. * @return \stdClass The map in JSON format corresponding to this object.
*/ */
function jsonSerialize(): \stdClass { function jsonSerialize(): \stdClass {
return (object) [ return (object) [
'description' => $this->getDescription(), 'description' => $this->getDescription(),
'id' => $this->getId(), 'id' => $this->getId(),
'name' => $this->getName(), 'name' => $this->getName(),
'permission' => $this->getPermission() 'permission' => $this->getPermission()
]; ];
} }
/** /**
* Sets the team description. * Sets the team description.
* @param string $value The new description. * @param string $value The new description.
* @return $this This instance. * @return $this This instance.
*/ */
function setDescription(string $value): self { function setDescription(string $value): self {
$this->description = $value; $this->description = $value;
return $this; return $this;
} }
/** /**
* Sets the team name. * Sets the team name.
* @param string $value The new name. * @param string $value The new name.
* @return $this This instance. * @return $this This instance.
*/ */
function setName(string $value): self { function setName(string $value): self {
$this->name = $value; $this->name = $value;
return $this; return $this;
} }
/** /**
* Sets the team permission. * Sets the team permission.
* @param string $value The new permission. * @param string $value The new permission.
* @return $this This instance. * @return $this This instance.
*/ */
function setPermission(string $value): self { function setPermission(string $value): self {
$this->permission = TeamPermission::coerce($value, TeamPermission::none); $this->permission = TeamPermission::coerce($value, TeamPermission::none);
return $this; return $this;
} }
} }

View File

@ -1,24 +1,24 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace Gitea\Models; namespace Gitea\Model;
use Enum\{EnumTrait}; use Enum\{EnumTrait};
/** Defines the permission of a team. */ /** Defines the permission of a team. */
final class TeamPermission { final class TeamPermission {
use EnumTrait; use EnumTrait;
/** @var string The team has the administrator permission. */ /** @var string The team has the administrator permission. */
const admin = 'admin'; const admin = 'admin';
/** @var string The team doesn't have any permission. */ /** @var string The team doesn't have any permission. */
const none = 'none'; const none = 'none';
/** @var string The team has the owner permission. */ /** @var string The team has the owner permission. */
const owner = 'owner'; const owner = 'owner';
/** @var string The team has the read permission. */ /** @var string The team has the read permission. */
const read = 'read'; const read = 'read';
/** @var string The team has the write permission. */ /** @var string The team has the write permission. */
const write = 'write'; const write = 'write';
} }

View File

@ -1,137 +1,137 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace Gitea\Models; namespace Gitea\Model;
/** Represents the worked time for an issue or pull request. */ /** Represents the worked time for an issue or pull request. */
class TrackedTime implements \JsonSerializable { class TrackedTime implements \JsonSerializable {
/** @var \DateTime|null The date the entry was created. */ /** @var \DateTime|null The date the entry was created. */
private $createdAt; private $createdAt;
/** @var int The entry identifier. */ /** @var int The entry identifier. */
private $id; private $id;
/** @var int The identifier of the associated issue or pull request. */ /** @var int The identifier of the associated issue or pull request. */
private $issueId = -1; private $issueId = -1;
/** @var int The elapsed time, in seconds. */ /** @var int The elapsed time, in seconds. */
private $time; private $time;
/** @var int The identifier of the initiating user. */ /** @var int The identifier of the initiating user. */
private $userId = -1; private $userId = -1;
/** /**
* Creates a new entry. * Creates a new entry.
* @param int $id The entry identifier. * @param int $id The entry identifier.
* @param int $time The elapsed time, in seconds. * @param int $time The elapsed time, in seconds.
*/ */
function __construct(int $id, int $time) { function __construct(int $id, int $time) {
$this->id = $id; $this->id = $id;
$this->setTime($time); $this->setTime($time);
} }
/** /**
* Creates a new entry from the specified JSON map. * Creates a new entry from the specified JSON map.
* @param object $map A JSON map representing an entry. * @param object $map A JSON map representing an entry.
* @return static The instance corresponding to the specified JSON map. * @return static The instance corresponding to the specified JSON map.
*/ */
static function fromJson(object $map): self { static function fromJson(object $map): self {
return (new static(isset($map->id) && is_int($map->id) ? $map->id : -1, isset($map->time) && is_int($map->time) ? $map->time : 0)) return (new static(isset($map->id) && is_int($map->id) ? $map->id : -1, isset($map->time) && is_int($map->time) ? $map->time : 0))
->setCreatedAt(isset($map->created) && is_string($map->created) ? new \DateTime($map->created) : null) ->setCreatedAt(isset($map->created) && is_string($map->created) ? new \DateTime($map->created) : null)
->setIssueId(isset($map->issue_id) && is_int($map->issue_id) ? $map->issue_id : -1) ->setIssueId(isset($map->issue_id) && is_int($map->issue_id) ? $map->issue_id : -1)
->setUserId(isset($map->user_id) && is_int($map->user_id) ? $map->user_id : -1); ->setUserId(isset($map->user_id) && is_int($map->user_id) ? $map->user_id : -1);
} }
/** /**
* Gets the date the entry was created. * Gets the date the entry was created.
* @return \DateTime|null The date the entry was created. * @return \DateTime|null The date the entry was created.
*/ */
function getCreatedAt(): ?\DateTime { function getCreatedAt(): ?\DateTime {
return $this->createdAt; return $this->createdAt;
} }
/** /**
* Gets the entry identifier. * Gets the entry identifier.
* @return int The entry identifier. * @return int The entry identifier.
*/ */
function getId(): int { function getId(): int {
return $this->id; return $this->id;
} }
/** /**
* Gets the identifier of the associated issue or pull request. * Gets the identifier of the associated issue or pull request.
* @return int The identifier of the associated issue or pull request. * @return int The identifier of the associated issue or pull request.
*/ */
function getIssueId(): int { function getIssueId(): int {
return $this->issueId; return $this->issueId;
} }
/** /**
* Gets the elapsed time, in seconds. * Gets the elapsed time, in seconds.
* @return int The elapsed time, in seconds. * @return int The elapsed time, in seconds.
*/ */
function getTime(): int { function getTime(): int {
return $this->time; return $this->time;
} }
/** /**
* Gets the identifier of the initiating user. * Gets the identifier of the initiating user.
* @return int The identifier of the initiating user. * @return int The identifier of the initiating user.
*/ */
function getUserId(): int { function getUserId(): int {
return $this->userId; return $this->userId;
} }
/** /**
* Converts this object to a map in JSON format. * Converts this object to a map in JSON format.
* @return \stdClass The map in JSON format corresponding to this object. * @return \stdClass The map in JSON format corresponding to this object.
*/ */
function jsonSerialize(): \stdClass { function jsonSerialize(): \stdClass {
return (object) [ return (object) [
'created' => ($date = $this->getCreatedAt()) ? $date->format('c') : null, 'created' => ($date = $this->getCreatedAt()) ? $date->format('c') : null,
'id' => $this->getId(), 'id' => $this->getId(),
'issue_id' => $this->getIssueId(), 'issue_id' => $this->getIssueId(),
'time' => $this->getTime(), 'time' => $this->getTime(),
'user_id' => $this->getUserId() 'user_id' => $this->getUserId()
]; ];
} }
/** /**
* Sets the date the entry was created. * Sets the date the entry was created.
* @param \DateTime|null $value The new date of creation. * @param \DateTime|null $value The new date of creation.
* @return $this This instance. * @return $this This instance.
*/ */
function setCreatedAt(?\DateTime $value): self { function setCreatedAt(?\DateTime $value): self {
$this->createdAt = $value; $this->createdAt = $value;
return $this; return $this;
} }
/** /**
* Sets the identifier of the associated issue or pull request. * Sets the identifier of the associated issue or pull request.
* @param int $value The new issue identifier. * @param int $value The new issue identifier.
* @return $this This instance. * @return $this This instance.
*/ */
function setIssueId(int $value): self { function setIssueId(int $value): self {
$this->issueId = $value; $this->issueId = $value;
return $this; return $this;
} }
/** /**
* Sets the elapsed time, in seconds. * Sets the elapsed time, in seconds.
* @param int $value The new elapsed time, in seconds. * @param int $value The new elapsed time, in seconds.
* @return $this This instance. * @return $this This instance.
*/ */
function setTime(int $value): self { function setTime(int $value): self {
$this->time = $value; $this->time = $value;
return $this; return $this;
} }
/** /**
* Sets the identifier of the initiating user. * Sets the identifier of the initiating user.
* @param int $value The new user identifier. * @param int $value The new user identifier.
* @return $this This instance. * @return $this This instance.
*/ */
function setUserId(int $value): self { function setUserId(int $value): self {
$this->userId = $value; $this->userId = $value;
return $this; return $this;
} }
} }

View File

@ -1,5 +1,5 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace Gitea\Models; namespace Gitea\Model;
use GuzzleHttp\Psr7\{Uri}; use GuzzleHttp\Psr7\{Uri};
use Psr\Http\Message\{UriInterface}; use Psr\Http\Message\{UriInterface};
@ -7,157 +7,157 @@ use Psr\Http\Message\{UriInterface};
/** Represents a Gitea user. */ /** Represents a Gitea user. */
class User implements \JsonSerializable { class User implements \JsonSerializable {
/** @var UriInterface|null The URL to the user's avatar. */ /** @var UriInterface|null The URL to the user's avatar. */
private $avatarUrl; private $avatarUrl;
/** @var string The mail address. */ /** @var string The mail address. */
private $email = ''; private $email = '';
/** @var string The full name. */ /** @var string The full name. */
private $fullName = ''; private $fullName = '';
/** @var int The user identifier. */ /** @var int The user identifier. */
private $id; private $id;
/** @var string The user locale. */ /** @var string The user locale. */
private $language = ''; private $language = '';
/** @var string The name of the Gitea account. */ /** @var string The name of the Gitea account. */
private $login; private $login;
/** /**
* Creates a new user. * Creates a new user.
* @param int $id The user identifier. * @param int $id The user identifier.
* @param string $login The name of the Gitea account. * @param string $login The name of the Gitea account.
*/ */
function __construct(int $id, string $login) { function __construct(int $id, string $login) {
$this->id = $id; $this->id = $id;
$this->setLogin($login); $this->setLogin($login);
} }
/** /**
* Creates a new user from the specified JSON map. * Creates a new user from the specified JSON map.
* @param object $map A JSON map representing a user. * @param object $map A JSON map representing a user.
* @return static The instance corresponding to the specified JSON map. * @return static The instance corresponding to the specified JSON map.
*/ */
static function fromJson(object $map): self { static function fromJson(object $map): self {
return (new static(isset($map->id) && is_int($map->id) ? $map->id : -1, isset($map->login) && is_string($map->login) ? $map->login : '')) return (new static(isset($map->id) && is_int($map->id) ? $map->id : -1, isset($map->login) && is_string($map->login) ? $map->login : ''))
->setAvatarUrl(isset($map->avatar_url) && is_string($map->avatar_url) ? new Uri($map->avatar_url) : null) ->setAvatarUrl(isset($map->avatar_url) && is_string($map->avatar_url) ? new Uri($map->avatar_url) : null)
->setEmail(isset($map->email) && is_string($map->email) ? mb_strtolower($map->email) : '') ->setEmail(isset($map->email) && is_string($map->email) ? mb_strtolower($map->email) : '')
->setFullName(isset($map->full_name) && is_string($map->full_name) ? $map->full_name : '') ->setFullName(isset($map->full_name) && is_string($map->full_name) ? $map->full_name : '')
->setLanguage(isset($map->language) && is_string($map->language) ? $map->language : ''); ->setLanguage(isset($map->language) && is_string($map->language) ? $map->language : '');
} }
/** /**
* Gets the URL of the avatar image. * Gets the URL of the avatar image.
* @return UriInterface|null The URL of the avatar image. * @return UriInterface|null The URL of the avatar image.
*/ */
function getAvatarUrl(): ?UriInterface { function getAvatarUrl(): ?UriInterface {
return $this->avatarUrl; return $this->avatarUrl;
} }
/** /**
* Gets the mail address. * Gets the mail address.
* @return string The mail address. * @return string The mail address.
*/ */
function getEmail(): string { function getEmail(): string {
return $this->email; return $this->email;
} }
/** /**
* Gets the full name. * Gets the full name.
* @return string The full name. * @return string The full name.
*/ */
function getFullName(): string { function getFullName(): string {
return $this->fullName; return $this->fullName;
} }
/** /**
* Gets the user identifier. * Gets the user identifier.
* @return int The user identifier. * @return int The user identifier.
*/ */
function getId(): int { function getId(): int {
return $this->id; return $this->id;
} }
/** /**
* Gets the user locale. * Gets the user locale.
* @return string The user locale. * @return string The user locale.
*/ */
function getLanguage(): string { function getLanguage(): string {
return $this->language; return $this->language;
} }
/** /**
* Gets the name of the Gitea account. * Gets the name of the Gitea account.
* @return string The name of the Gitea account. * @return string The name of the Gitea account.
*/ */
function getLogin(): string { function getLogin(): string {
return $this->login; return $this->login;
} }
/** /**
* Converts this object to a map in JSON format. * Converts this object to a map in JSON format.
* @return \stdClass The map in JSON format corresponding to this object. * @return \stdClass The map in JSON format corresponding to this object.
*/ */
function jsonSerialize(): \stdClass { function jsonSerialize(): \stdClass {
return (object) [ return (object) [
'avatar_url' => ($url = $this->getAvatarUrl()) ? (string) $url : null, 'avatar_url' => ($url = $this->getAvatarUrl()) ? (string) $url : null,
'email' => $this->getEmail(), 'email' => $this->getEmail(),
'full_name' => $this->getFullName(), 'full_name' => $this->getFullName(),
'id' => $this->getId(), 'id' => $this->getId(),
'language' => $this->getLanguage(), 'language' => $this->getLanguage(),
'login' => $this->getLogin() 'login' => $this->getLogin()
]; ];
} }
/** /**
* Sets the URL of the avatar image. * Sets the URL of the avatar image.
* @param UriInterface|null $value The new avatar URL. * @param UriInterface|null $value The new avatar URL.
* @return $this This instance. * @return $this This instance.
*/ */
function setAvatarUrl(?UriInterface $value): self { function setAvatarUrl(?UriInterface $value): self {
$this->avatarUrl = $value; $this->avatarUrl = $value;
return $this; return $this;
} }
/** /**
* Sets the mail address. * Sets the mail address.
* @param string $value The new mail address. * @param string $value The new mail address.
* @return $this This instance. * @return $this This instance.
*/ */
function setEmail(string $value): self { function setEmail(string $value): self {
$this->email = $value; $this->email = $value;
return $this; return $this;
} }
/** /**
* Sets the full name. * Sets the full name.
* @param string $value The new full name. * @param string $value The new full name.
* @return $this This instance. * @return $this This instance.
*/ */
function setFullName(string $value): self { function setFullName(string $value): self {
$this->fullName = $value; $this->fullName = $value;
return $this; return $this;
} }
/** /**
* Sets the user locale. * Sets the user locale.
* @param string $value The new user locale. * @param string $value The new user locale.
* @return $this This instance. * @return $this This instance.
*/ */
function setLanguage(string $value): self { function setLanguage(string $value): self {
$this->language = $value; $this->language = $value;
return $this; return $this;
} }
/** /**
* Sets the name of the Gitea account. * Sets the name of the Gitea account.
* @param string $value The new Gitea account. * @param string $value The new Gitea account.
* @return $this This instance. * @return $this This instance.
*/ */
function setLogin(string $value): self { function setLogin(string $value): self {
$this->login = $value; $this->login = $value;
return $this; return $this;
} }
} }

View File

@ -8,232 +8,232 @@ use Psr\Http\Message\{UriInterface};
/** Represents a Gitea push event. */ /** Represents a Gitea push event. */
class PushEvent implements \JsonSerializable { class PushEvent implements \JsonSerializable {
/** @var string The hash of the new Git revision. */ /** @var string The hash of the new Git revision. */
private $after = ''; private $after = '';
/** @var string The hash of the previous Git revision. */ /** @var string The hash of the previous Git revision. */
private $before = ''; private $before = '';
/** @var \ArrayObject The revision commits. */ /** @var \ArrayObject The revision commits. */
private $commits; private $commits;
/** @var UriInterface|null The URL for comparing the revisions. */ /** @var UriInterface|null The URL for comparing the revisions. */
private $compareUrl; private $compareUrl;
/** @var User|null The user who pushed the commits. */ /** @var User|null The user who pushed the commits. */
private $pusher; private $pusher;
/** @var string The Git reference. */ /** @var string The Git reference. */
private $ref = ''; private $ref = '';
/** @var Repository|null The repository where the commits were pushed. */ /** @var Repository|null The repository where the commits were pushed. */
private $repository; private $repository;
/** @var string The secret used to validate this event. */ /** @var string The secret used to validate this event. */
private $secret = ''; private $secret = '';
/** @var User|null The user who sent this event. */ /** @var User|null The user who sent this event. */
private $sender; private $sender;
/** Creates a new event. */ /** Creates a new event. */
function __construct() { function __construct() {
$this->commits = new \ArrayObject; $this->commits = new \ArrayObject;
} }
/** /**
* Creates a new event from the specified JSON map. * Creates a new event from the specified JSON map.
* @param object $map A JSON map representing an event. * @param object $map A JSON map representing an event.
* @return static The instance corresponding to the specified JSON map. * @return static The instance corresponding to the specified JSON map.
*/ */
static function fromJson(object $map): self { static function fromJson(object $map): self {
return (new static) return (new static)
->setAfter(isset($map->after) && is_string($map->after) ? $map->after : '') ->setAfter(isset($map->after) && is_string($map->after) ? $map->after : '')
->setBefore(isset($map->before) && is_string($map->before) ? $map->before : '') ->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) ->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) : []) ->setCommits(isset($map->commits) && is_array($map->commits) ? array_map([PayloadCommit::class, 'fromJson'], $map->commits) : [])
->setPusher(isset($map->pusher) && is_object($map->pusher) ? User::fromJson($map->pusher) : null) ->setPusher(isset($map->pusher) && is_object($map->pusher) ? User::fromJson($map->pusher) : null)
->setRef(isset($map->ref) && is_string($map->ref) ? $map->ref : '') ->setRef(isset($map->ref) && is_string($map->ref) ? $map->ref : '')
->setRepository(isset($map->repository) && is_object($map->repository) ? Repository::fromJson($map->repository) : null) ->setRepository(isset($map->repository) && is_object($map->repository) ? Repository::fromJson($map->repository) : null)
->setSecret(isset($map->secret) && is_string($map->secret) ? $map->secret : '') ->setSecret(isset($map->secret) && is_string($map->secret) ? $map->secret : '')
->setSender(isset($map->sender) && is_object($map->sender) ? User::fromJson($map->sender) : null); ->setSender(isset($map->sender) && is_object($map->sender) ? User::fromJson($map->sender) : null);
} }
/** /**
* Gets the hash of the new Git revision. * Gets the hash of the new Git revision.
* @return string The hash of the new Git revision. * @return string The hash of the new Git revision.
*/ */
function getAfter(): string { function getAfter(): string {
return $this->after; return $this->after;
} }
/** /**
* Gets the hash of the new previous revision. * Gets the hash of the new previous revision.
* @return string The hash of the previous Git revision. * @return string The hash of the previous Git revision.
*/ */
function getBefore(): string { function getBefore(): string {
return $this->before; return $this->before;
} }
/** /**
* Gets the revision commits. * Gets the revision commits.
* @return \ArrayObject The revision commits. * @return \ArrayObject The revision commits.
*/ */
function getCommits(): \ArrayObject { function getCommits(): \ArrayObject {
return $this->commits; return $this->commits;
} }
/** /**
* Gets the URL for comparing the revisions. * Gets the URL for comparing the revisions.
* @return UriInterface|null The URL for comparing the revisions. * @return UriInterface|null The URL for comparing the revisions.
*/ */
function getCompareUrl(): ?UriInterface { function getCompareUrl(): ?UriInterface {
return $this->compareUrl; return $this->compareUrl;
} }
/** /**
* Gets the user who pushed the commits. * Gets the user who pushed the commits.
* @return User|null The user who pushed the commits. * @return User|null The user who pushed the commits.
*/ */
function getPusher(): ?User { function getPusher(): ?User {
return $this->pusher; return $this->pusher;
} }
/** /**
* Gets the Git reference. * Gets the Git reference.
* @return string The Git reference. * @return string The Git reference.
*/ */
function getRef(): string { function getRef(): string {
return $this->ref; return $this->ref;
} }
/** /**
* Gets the repository where the commits were pushed. * Gets the repository where the commits were pushed.
* @return Repository|null The repository where the commits were pushed. * @return Repository|null The repository where the commits were pushed.
*/ */
function getRepository(): ?Repository { function getRepository(): ?Repository {
return $this->repository; return $this->repository;
} }
/** /**
* Gets the secret used to validate this event. * Gets the secret used to validate this event.
* @return string The secret used to validate this event. * @return string The secret used to validate this event.
*/ */
function getSecret(): string { function getSecret(): string {
return $this->secret; return $this->secret;
} }
/** /**
* Gets the user who sent this event. * Gets the user who sent this event.
* @return User|null The user who sent this event. * @return User|null The user who sent this event.
*/ */
function getSender(): ?User { function getSender(): ?User {
return $this->sender; return $this->sender;
} }
/** /**
* Converts this object to a map in JSON format. * Converts this object to a map in JSON format.
* @return \stdClass The map in JSON format corresponding to this object. * @return \stdClass The map in JSON format corresponding to this object.
*/ */
function jsonSerialize(): \stdClass { function jsonSerialize(): \stdClass {
return (object) [ return (object) [
'after' => $this->getAfter(), 'after' => $this->getAfter(),
'before' => $this->getBefore(), 'before' => $this->getBefore(),
'compare_url' => ($url = $this->getCompareUrl()) ? (string) $url : null, 'compare_url' => ($url = $this->getCompareUrl()) ? (string) $url : null,
'commits' => array_map(function(PayloadCommit $commit) { return $commit->jsonSerialize(); }, $this->getCommits()->getArrayCopy()), 'commits' => array_map(function(PayloadCommit $commit) { return $commit->jsonSerialize(); }, $this->getCommits()->getArrayCopy()),
'pusher' => ($user = $this->getPusher()) ? $user->jsonSerialize() : null, 'pusher' => ($user = $this->getPusher()) ? $user->jsonSerialize() : null,
'ref' => $this->getRef(), 'ref' => $this->getRef(),
'repository' => ($repository = $this->getRepository()) ? $repository->jsonSerialize() : null, 'repository' => ($repository = $this->getRepository()) ? $repository->jsonSerialize() : null,
'sender' => ($user = $this->getSender()) ? $user->jsonSerialize() : null 'sender' => ($user = $this->getSender()) ? $user->jsonSerialize() : null
]; ];
} }
/** /**
* Sets the hash of the new Git revision. * Sets the hash of the new Git revision.
* @param string $value The hash of the new Git revision. * @param string $value The hash of the new Git revision.
* @return $this This instance. * @return $this This instance.
*/ */
function setAfter(string $value): self { function setAfter(string $value): self {
$this->after = $value; $this->after = $value;
return $this; return $this;
} }
/** /**
* Sets the hash of the new previous revision. * Sets the hash of the new previous revision.
* @param string $value The hash of the new previous revision. * @param string $value The hash of the new previous revision.
* @return $this This instance. * @return $this This instance.
*/ */
function setBefore(string $value): self { function setBefore(string $value): self {
$this->before = $value; $this->before = $value;
return $this; return $this;
} }
/** /**
* Sets the revision commits. * Sets the revision commits.
* @param PayloadCommit[] $values The revision commits. * @param PayloadCommit[] $values The revision commits.
* @return $this This instance. * @return $this This instance.
*/ */
function setCommits(array $values): self { function setCommits(array $values): self {
$this->getCommits()->exchangeArray($values); $this->getCommits()->exchangeArray($values);
return $this; return $this;
} }
/** /**
* Sets the URL for comparing the revisions. * Sets the URL for comparing the revisions.
* @param UriInterface|null $value The URL for comparing the revisions. * @param UriInterface|null $value The URL for comparing the revisions.
* @return $this This instance. * @return $this This instance.
*/ */
function setCompareUrl(?UriInterface $value): self { function setCompareUrl(?UriInterface $value): self {
$this->compareUrl = $value; $this->compareUrl = $value;
return $this; return $this;
} }
/** /**
* Sets the user who pushed the commits. * Sets the user who pushed the commits.
* @param User|null $value The new pusher. * @param User|null $value The new pusher.
* @return $this This instance. * @return $this This instance.
*/ */
function setPusher(?User $value): self { function setPusher(?User $value): self {
$this->pusher = $value; $this->pusher = $value;
return $this; return $this;
} }
/** /**
* Sets the Git reference. * Sets the Git reference.
* @param string $value The new Git reference. * @param string $value The new Git reference.
* @return $this This instance. * @return $this This instance.
*/ */
function setRef(string $value): self { function setRef(string $value): self {
$this->ref = $value; $this->ref = $value;
return $this; return $this;
} }
/** /**
* Sets the repository where the commits were pushed. * Sets the repository where the commits were pushed.
* @param Repository|null $value The new repository. * @param Repository|null $value The new repository.
* @return $this This instance. * @return $this This instance.
*/ */
function setRepository(?Repository $value): self { function setRepository(?Repository $value): self {
$this->repository = $value; $this->repository = $value;
return $this; return $this;
} }
/** /**
* Sets the secret used to validate this event. * Sets the secret used to validate this event.
* @param string $value The new secret used to validate this event. * @param string $value The new secret used to validate this event.
* @return $this This instance. * @return $this This instance.
*/ */
function setSecret(string $value): self { function setSecret(string $value): self {
$this->secret = $value; $this->secret = $value;
return $this; return $this;
} }
/** /**
* Sets the user who sent this event. * Sets the user who sent this event.
* @param User|null $value The new sender. * @param User|null $value The new sender.
* @return $this This instance. * @return $this This instance.
*/ */
function setSender(?User $value): self { function setSender(?User $value): self {
$this->sender = $value; $this->sender = $value;
return $this; return $this;
} }
} }