mirror of
				https://github.com/sitelease/sugar-cube-client.git
				synced 2025-10-31 12:02:30 +01:00 
			
		
		
		
	Renamed the 'lib' folder to 'src'
This commit is contained in:
		
							
								
								
									
										261
									
								
								src/PushEvent.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										261
									
								
								src/PushEvent.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,261 @@ | ||||
| <?php declare(strict_types=1); | ||||
| namespace Gitea; | ||||
|  | ||||
| use Gitea\Models\{PayloadCommit, Repository, User}; | ||||
| use GuzzleHttp\Psr7\{Uri}; | ||||
| use Psr\Http\Message\{UriInterface}; | ||||
|  | ||||
| /** | ||||
|  * Represents a Gitea push event. | ||||
|  */ | ||||
| class PushEvent implements \JsonSerializable { | ||||
|  | ||||
|   /** | ||||
|    * @var string The hash of the new Git revision. | ||||
|    */ | ||||
|   private $after = ''; | ||||
|  | ||||
|   /** | ||||
|    * @var string The hash of the previous Git revision. | ||||
|    */ | ||||
|   private $before = ''; | ||||
|  | ||||
|   /** | ||||
|    * @var \ArrayObject The revision commits. | ||||
|    */ | ||||
|   private $commits; | ||||
|  | ||||
|   /** | ||||
|    * @var UriInterface|null The URL for comparing the revisions. | ||||
|    */ | ||||
|   private $compareUrl; | ||||
|  | ||||
|   /** | ||||
|    * @var User|null The user who pushed the commits. | ||||
|    */ | ||||
|   private $pusher; | ||||
|  | ||||
|   /** | ||||
|    * @var string The Git reference. | ||||
|    */ | ||||
|   private $ref = ''; | ||||
|  | ||||
|   /** | ||||
|    * @var Repository|null The repository where the commits were pushed. | ||||
|    */ | ||||
|   private $repository; | ||||
|  | ||||
|   /** | ||||
|    * @var string The secret used to validate this event. | ||||
|    */ | ||||
|   private $secret = ''; | ||||
|  | ||||
|   /** | ||||
|    * @var User|null The user who sent this event. | ||||
|    */ | ||||
|   private $sender; | ||||
|  | ||||
|   /** | ||||
|    * Creates a new event. | ||||
|    */ | ||||
|   function __construct() { | ||||
|     $this->commits = new \ArrayObject; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Creates a new event from the specified JSON map. | ||||
|    * @param object $map A JSON map representing an event. | ||||
|    * @return static The instance corresponding to the specified JSON map. | ||||
|    */ | ||||
|   static function fromJson(object $map): self { | ||||
|     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) : []) | ||||
|       ->setPusher(isset($map->pusher) && is_object($map->pusher) ? User::fromJson($map->pusher) : null) | ||||
|       ->setRef(isset($map->ref) && is_string($map->ref) ? $map->ref : '') | ||||
|       ->setRepository(isset($map->repository) && is_object($map->repository) ? Repository::fromJson($map->repository) : null) | ||||
|       ->setSecret(isset($map->secret) && is_string($map->secret) ? $map->secret : '') | ||||
|       ->setSender(isset($map->sender) && is_object($map->sender) ? User::fromJson($map->sender) : null); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the hash of the new Git revision. | ||||
|    * @return string The hash of the new Git revision. | ||||
|    */ | ||||
|   function getAfter(): string { | ||||
|     return $this->after; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the hash of the new previous revision. | ||||
|    * @return string The hash of the previous Git revision. | ||||
|    */ | ||||
|   function getBefore(): string { | ||||
|     return $this->before; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the revision commits. | ||||
|    * @return \ArrayObject The revision commits. | ||||
|    */ | ||||
|   function getCommits(): \ArrayObject { | ||||
|     return $this->commits; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the URL for comparing the revisions. | ||||
|    * @return UriInterface|null The URL for comparing the revisions. | ||||
|    */ | ||||
|   function getCompareUrl(): ?UriInterface { | ||||
|     return $this->compareUrl; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the user who pushed the commits. | ||||
|    * @return User|null The user who pushed the commits. | ||||
|    */ | ||||
|   function getPusher(): ?User { | ||||
|     return $this->pusher; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the Git reference. | ||||
|    * @return string The Git reference. | ||||
|    */ | ||||
|   function getRef(): string { | ||||
|     return $this->ref; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the repository where the commits were pushed. | ||||
|    * @return Repository|null The repository where the commits were pushed. | ||||
|    */ | ||||
|   function getRepository(): ?Repository { | ||||
|     return $this->repository; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the secret used to validate this event. | ||||
|    * @return string The secret used to validate this event. | ||||
|    */ | ||||
|   function getSecret(): string { | ||||
|     return $this->secret; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the user who sent this event. | ||||
|    * @return User|null The user who sent this event. | ||||
|    */ | ||||
|   function getSender(): ?User { | ||||
|     return $this->sender; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Converts this object to a map in JSON format. | ||||
|    * @return \stdClass The map in JSON format corresponding to this object. | ||||
|    */ | ||||
|   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' => ($user = $this->getPusher()) ? $user->jsonSerialize() : null, | ||||
|       'ref' => $this->getRef(), | ||||
|       'repository' => ($repository = $this->getRepository()) ? $repository->jsonSerialize() : null, | ||||
|       'sender' => ($user = $this->getSender()) ? $user->jsonSerialize() : null | ||||
|     ]; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the hash of the new Git revision. | ||||
|    * @param string $value The hash of the new Git revision. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setAfter(string $value): self { | ||||
|     $this->after = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the hash of the new previous revision. | ||||
|    * @param string $value The hash of the new previous revision. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setBefore(string $value): self { | ||||
|     $this->before = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the revision commits. | ||||
|    * @param PayloadCommit[] $values The revision commits. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setCommits(array $values): self { | ||||
|     $this->getCommits()->exchangeArray($values); | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the URL for comparing the revisions. | ||||
|    * @param UriInterface|null $value The URL for comparing the revisions. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setCompareUrl(?UriInterface $value): self { | ||||
|     $this->compareUrl = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the user who pushed the commits. | ||||
|    * @param User|null $value The new pusher. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setPusher(?User $value): self { | ||||
|     $this->pusher = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the Git reference. | ||||
|    * @param string $value The new Git reference. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setRef(string $value): self { | ||||
|     $this->ref = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the repository where the commits were pushed. | ||||
|    * @param Repository|null $value The new repository. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setRepository(?Repository $value): self { | ||||
|     $this->repository = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the secret used to validate this event. | ||||
|    * @param string $value The new secret used to validate this event. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setSecret(string $value): self { | ||||
|     $this->secret = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the user who sent this event. | ||||
|    * @param User|null $value The new sender. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setSender(?User $value): self { | ||||
|     $this->sender = $value; | ||||
|     return $this; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										202
									
								
								src/models/PayloadCommit.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										202
									
								
								src/models/PayloadCommit.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,202 @@ | ||||
| <?php declare(strict_types=1); | ||||
| namespace Gitea\Models; | ||||
|  | ||||
| use GuzzleHttp\Psr7\{Uri}; | ||||
| use Psr\Http\Message\{UriInterface}; | ||||
|  | ||||
| /** | ||||
|  * Represents a commit. | ||||
|  */ | ||||
| class PayloadCommit implements \JsonSerializable { | ||||
|  | ||||
|   /** | ||||
|    * @var PayloadUser|null The person who authored the commit. | ||||
|    */ | ||||
|   private $author; | ||||
|  | ||||
|   /** | ||||
|    * @var PayloadUser|null The person who committed the code. | ||||
|    */ | ||||
|   private $committer; | ||||
|  | ||||
|   /** | ||||
|    * @var string The commit hash. | ||||
|    */ | ||||
|   private $id; | ||||
|  | ||||
|   /** | ||||
|    * @var string The commit message. | ||||
|    */ | ||||
|   private $message; | ||||
|  | ||||
|   /** | ||||
|    * @var \DateTime|null The commit date. | ||||
|    */ | ||||
|   private $timestamp; | ||||
|  | ||||
|   /** | ||||
|    * @var UriInterface|null The URL to the commit's history. | ||||
|    */ | ||||
|   private $url; | ||||
|  | ||||
|   /** | ||||
|    * @var PayloadCommitVerification|null The GPG verification of this commit. | ||||
|    */ | ||||
|   private $verification; | ||||
|  | ||||
|   /** | ||||
|    * Creates a new payload commit. | ||||
|    * @param string $id The commit hash. | ||||
|    * @param string $message The commit message. | ||||
|    */ | ||||
|   function __construct(string $id, string $message) { | ||||
|     $this->id = $id; | ||||
|     $this->setMessage($message); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Creates a new commit from the specified JSON map. | ||||
|    * @param object $map A JSON map representing a commit. | ||||
|    * @return static The instance corresponding to the specified JSON map. | ||||
|    */ | ||||
|   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 : '')) | ||||
|       ->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) | ||||
|       ->setTimestamp(isset($map->timestamp) && is_string($map->timestamp) ? new \DateTime($map->timestamp) : null) | ||||
|       ->setUrl(isset($map->url) && is_string($map->url) ? new Uri($map->url) : null) | ||||
|       ->setVerification(isset($map->verification) && is_object($map->verification) ? PayloadCommitVerification::fromJson($map->verification) : null); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the person who authored the commit. | ||||
|    * @return PayloadUser|null The person who authored the commit. | ||||
|    */ | ||||
|   function getAuthor(): ?PayloadUser { | ||||
|     return $this->author; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the person who committed the code. | ||||
|    * @return PayloadUser|null The person who committed the code. | ||||
|    */ | ||||
|   function getCommitter(): ?PayloadUser { | ||||
|     return $this->committer; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the commit hash. | ||||
|    * @return string The commit hash. | ||||
|    */ | ||||
|   function getId(): string { | ||||
|     return $this->id; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the commit message. | ||||
|    * @return string The commit message. | ||||
|    */ | ||||
|   function getMessage(): string { | ||||
|     return $this->message; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the commit date. | ||||
|    * @return \DateTime|null The commit date. | ||||
|    */ | ||||
|   function getTimestamp(): ?\DateTime { | ||||
|     return $this->timestamp; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the URL to the commit's history. | ||||
|    * @return UriInterface|null The URL to the commit's history. | ||||
|    */ | ||||
|   function getUrl(): ?UriInterface { | ||||
|     return $this->url; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the GPG verification of this commit. | ||||
|    * @return PayloadCommitVerification|null The GPG verification of this commit. | ||||
|    */ | ||||
|   function getVerification(): ?PayloadCommitVerification { | ||||
|     return $this->verification; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Converts this object to a map in JSON format. | ||||
|    * @return \stdClass The map in JSON format corresponding to this object. | ||||
|    */ | ||||
|   function jsonSerialize(): \stdClass { | ||||
|     return (object) [ | ||||
|       'author' => ($author = $this->getAuthor()) ? $author->jsonSerialize() : null, | ||||
|       'committer' => ($committer = $this->getCommitter()) ? $committer->jsonSerialize() : null, | ||||
|       'id' => $this->getId(), | ||||
|       'message' => $this->getMessage(), | ||||
|       'timestamp' => ($date = $this->getTimestamp()) ? $date->format('c') : null, | ||||
|       'url' => ($url = $this->getUrl()) ? (string) $url : null, | ||||
|       'verification' => ($verification = $this->getVerification()) ? $verification->jsonSerialize() : null | ||||
|     ]; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the person who authored the commit. | ||||
|    * @param PayloadUser|null $value The new author. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setAuthor(?PayloadUser $value): self { | ||||
|     $this->author = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the person who committed the code. | ||||
|    * @param PayloadUser|null $value The new committer. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setCommitter(?PayloadUser $value): self { | ||||
|     $this->committer = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the commit message. | ||||
|    * @param string $value The new message. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setMessage(string $value): self { | ||||
|     $this->message = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the commit date. | ||||
|    * @param \DateTime|null $value The new commit date. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setTimestamp(?\DateTime $value): self { | ||||
|     $this->timestamp = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the URL to the commit's history. | ||||
|    * @param UriInterface|null $value The new commit URL. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setUrl(?UriInterface $value): self { | ||||
|     $this->url = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the commit message. | ||||
|    * @param PayloadCommitVerification|null $value The new message. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setVerification(?PayloadCommitVerification $value): self { | ||||
|     $this->verification = $value; | ||||
|     return $this; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										133
									
								
								src/models/PayloadCommitVerification.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										133
									
								
								src/models/PayloadCommitVerification.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,133 @@ | ||||
| <?php declare(strict_types=1); | ||||
| namespace Gitea\Models; | ||||
|  | ||||
| /** | ||||
|  * Represents the GPG verification of a commit. | ||||
|  */ | ||||
| class PayloadCommitVerification implements \JsonSerializable { | ||||
|  | ||||
|   /** | ||||
|    * @var bool Value indicating whether the verification has succeeded. | ||||
|    */ | ||||
|   private $isVerified; | ||||
|  | ||||
|   /** | ||||
|    * @var string A custom message sent with the verification request. | ||||
|    */ | ||||
|   private $payload = ''; | ||||
|  | ||||
|   /** | ||||
|    * @var string A message providing details about the verification. | ||||
|    */ | ||||
|   private $reason = ''; | ||||
|  | ||||
|   /** | ||||
|    * @var string The signing key used for the verification. | ||||
|    */ | ||||
|   private $signature = ''; | ||||
|  | ||||
|   /** | ||||
|    * Creates a new verification of a payload commit. | ||||
|    * @param bool $isVerified Value indicating whether the verification has succeeded. | ||||
|    */ | ||||
|   function __construct(bool $isVerified = false) { | ||||
|     $this->setVerified($isVerified); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Creates a new commit from the specified JSON map. | ||||
|    * @param object $map A JSON map representing a commit. | ||||
|    * @return static The instance corresponding to the specified JSON map. | ||||
|    */ | ||||
|   static function fromJson(object $map): self { | ||||
|     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 : ''); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the custom message sent with the verification request. | ||||
|    * @return string The custom message sent with the verification request. | ||||
|    */ | ||||
|   function getPayload(): string { | ||||
|     return $this->payload; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the message providing details about the verification. | ||||
|    * @return string The message providing details about the verification. | ||||
|    */ | ||||
|   function getReason(): string { | ||||
|     return $this->reason; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the signing key used for the verification. | ||||
|    * @return string The signing key used for the verification. | ||||
|    */ | ||||
|   function getSignature(): string { | ||||
|     return $this->signature; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * 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; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Converts this object to a map in JSON format. | ||||
|    * @return \stdClass The map in JSON format corresponding to this object. | ||||
|    */ | ||||
|   function jsonSerialize(): \stdClass { | ||||
|     return (object) [ | ||||
|       'payload' => $this->getPayload(), | ||||
|       'reason' => $this->getReason(), | ||||
|       'signature' => $this->getSignature(), | ||||
|       '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; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										98
									
								
								src/models/PayloadUser.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								src/models/PayloadUser.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,98 @@ | ||||
| <?php declare(strict_types=1); | ||||
| namespace Gitea\Models; | ||||
|  | ||||
| /** | ||||
|  * Represents the author or committer of a commit. | ||||
|  */ | ||||
| class PayloadUser implements \JsonSerializable { | ||||
|  | ||||
|   /** | ||||
|    * @var string The mail address. | ||||
|    */ | ||||
|   private $email = ''; | ||||
|  | ||||
|   /** | ||||
|    * @var string The full name. | ||||
|    */ | ||||
|   private $name = ''; | ||||
|  | ||||
|   /** | ||||
|    * @var string The name of the Gitea account. | ||||
|    */ | ||||
|   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. | ||||
|    * @param object $map A JSON map representing a user. | ||||
|    * @return static The instance corresponding to the specified JSON map. | ||||
|    */ | ||||
|   static function fromJson(object $map): self { | ||||
|     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; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Converts this object to a map in JSON format. | ||||
|    * @return \stdClass The map in JSON format corresponding to this object. | ||||
|    */ | ||||
|   function jsonSerialize(): \stdClass { | ||||
|     return (object) [ | ||||
|       '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; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										112
									
								
								src/models/Permission.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										112
									
								
								src/models/Permission.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,112 @@ | ||||
| <?php declare(strict_types=1); | ||||
| namespace Gitea\Models; | ||||
|  | ||||
| /** | ||||
|  * Represents a set of permissions. | ||||
|  */ | ||||
| class Permission implements \JsonSerializable { | ||||
|  | ||||
|   /** | ||||
|    * @var bool Value indicating whether administrator access is allowed. | ||||
|    */ | ||||
|   private $admin; | ||||
|  | ||||
|   /** | ||||
|    * @var bool Value indicating whether pull is allowed. | ||||
|    */ | ||||
|   private $pull; | ||||
|  | ||||
|   /** | ||||
|    * @var bool Value indicating whether push is allowed. | ||||
|    */ | ||||
|   private $push; | ||||
|  | ||||
|   /** | ||||
|    * Creates a new permission. | ||||
|    * @param bool $admin Value indicating whether administrator access is allowed. | ||||
|    * @param bool $pull Value indicating whether pull is allowed. | ||||
|    * @param bool $push Value indicating whether push is allowed. | ||||
|    */ | ||||
|   function __construct(bool $admin = false, bool $pull = false, bool $push = false) { | ||||
|     $this->setAdmin($admin)->setPull($pull)->setPush($push); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Creates a new user from the specified JSON map. | ||||
|    * @param object $map A JSON map representing a user. | ||||
|    * @return static The instance corresponding to the specified JSON map. | ||||
|    */ | ||||
|   static function fromJson(object $map): self { | ||||
|     return new static( | ||||
|       isset($map->admin) && is_bool($map->admin) ? $map->admin : false, | ||||
|       isset($map->pull) && is_bool($map->pull) ? $map->pull : false, | ||||
|       isset($map->push) && is_bool($map->push) ? $map->push : false | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets a value indicating whether administrator access is allowed. | ||||
|    * @return bool `true` if administrator access is allowed, otherwise `false`. | ||||
|    */ | ||||
|   function getAdmin(): bool { | ||||
|     return $this->admin; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets a value indicating whether pull is allowed. | ||||
|    * @return bool `true` if pull is allowed, otherwise `false`. | ||||
|    */ | ||||
|   function getPull(): bool { | ||||
|     return $this->pull; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets a value indicating whether push is allowed. | ||||
|    * @return bool `true` if push is allowed, otherwise `false`. | ||||
|    */ | ||||
|   function getPush(): bool { | ||||
|     return $this->push; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Converts this object to a map in JSON format. | ||||
|    * @return \stdClass The map in JSON format corresponding to this object. | ||||
|    */ | ||||
|   function jsonSerialize(): \stdClass { | ||||
|     return (object) [ | ||||
|       'admin' => $this->getAdmin(), | ||||
|       'pull' => $this->getPull(), | ||||
|       'push' => $this->getPush() | ||||
|     ]; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets a value indicating whether administrator access is allowed. | ||||
|    * @param bool $value `true` to allow administrator access, otherwise `false`. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setAdmin(bool $value): self { | ||||
|     $this->admin = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets a value indicating whether pull is allowed. | ||||
|    * @param bool $value `true` to allow pull, otherwise `false`. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setPull(bool $value): self { | ||||
|     $this->pull = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets a value indicating whether push is allowed. | ||||
|    * @param bool $value `true` to allow push, otherwise `false`. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setPush(bool $value): self { | ||||
|     $this->push = $value; | ||||
|     return $this; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										603
									
								
								src/models/Repository.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										603
									
								
								src/models/Repository.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,603 @@ | ||||
| <?php declare(strict_types=1); | ||||
| namespace Gitea\Models; | ||||
|  | ||||
| use GuzzleHttp\Psr7\{Uri}; | ||||
| use Psr\Http\Message\{UriInterface}; | ||||
|  | ||||
| /** | ||||
|  * Represents a repository. | ||||
|  */ | ||||
| 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. | ||||
|    */ | ||||
|   private $defaultBranch = ''; | ||||
|  | ||||
|   /** | ||||
|    * @var string The repository description. | ||||
|    */ | ||||
|   private $description = ''; | ||||
|  | ||||
|   /** | ||||
|    * @var int The number of forks of this repository. | ||||
|    */ | ||||
|   private $forksCount = 0; | ||||
|  | ||||
|   /** | ||||
|    * @var string The full name. | ||||
|    */ | ||||
|   private $fullName; | ||||
|  | ||||
|   /** | ||||
|    * @var UriInterface|null The Gitea URL of this repository. | ||||
|    */ | ||||
|   private $htmlUrl; | ||||
|  | ||||
|   /** | ||||
|    * @var int The repository identifier. | ||||
|    */ | ||||
|   private $id; | ||||
|  | ||||
|   /** | ||||
|    * @var bool Value indicating whether this repository is empty. | ||||
|    */ | ||||
|   private $isEmpty = true; | ||||
|  | ||||
|   /** | ||||
|    * @var bool Value indicating whether this repository is a fork. | ||||
|    */ | ||||
|   private $isFork = false; | ||||
|  | ||||
|   /** | ||||
|    * @var bool Value indicating whether this repository is a mirror. | ||||
|    */ | ||||
|   private $isMirror = false; | ||||
|  | ||||
|   /** | ||||
|    * @var bool Value indicating whether this repository is private. | ||||
|    */ | ||||
|   private $isPrivate = false; | ||||
|  | ||||
|   /** | ||||
|    * @var string The repository name. | ||||
|    */ | ||||
|   private $name = ''; | ||||
|  | ||||
|   /** | ||||
|    * @var int The number of open issues of this repository. | ||||
|    */ | ||||
|   private $openIssuesCount = 0; | ||||
|  | ||||
|   /** | ||||
|    * @var User|null The repository owner. | ||||
|    */ | ||||
|   private $owner; | ||||
|  | ||||
|   /** | ||||
|    * @var Repository|null The parent repository, if this repository is a fork or a mirror. | ||||
|    */ | ||||
|   private $parent; | ||||
|  | ||||
|   /** | ||||
|    * @var Permission|null The repository permissions. | ||||
|    */ | ||||
|   private $permissions; | ||||
|  | ||||
|   /** | ||||
|    * @var int The repository size, in kilobytes. | ||||
|    */ | ||||
|   private $size = 0; | ||||
|  | ||||
|   /** | ||||
|    * @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(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); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the HTTP-based URL for cloning this repository. | ||||
|    * @return UriInterface|null The HTTP-based URL for cloning this repository. | ||||
|    */ | ||||
|   function getCloneUrl(): ?UriInterface { | ||||
|     return $this->cloneUrl; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the date the repository was created. | ||||
|    * @return \DateTime|null The date the repository was created. | ||||
|    */ | ||||
|   function getCreatedAt(): ?\DateTime { | ||||
|     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. | ||||
|    */ | ||||
|   function getHtmlUrl(): ?UriInterface { | ||||
|     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)[1] : ''; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * 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 Repository|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. | ||||
|    */ | ||||
|   function getSshUrl(): ?UriInterface { | ||||
|     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. | ||||
|    */ | ||||
|   function getUpdatedAt(): ?\DateTime { | ||||
|     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. | ||||
|    */ | ||||
|   function getWebsite(): ?UriInterface { | ||||
|     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. | ||||
|    */ | ||||
|   function jsonSerialize(): \stdClass { | ||||
|     return (object) [ | ||||
|       'clone_url' => ($url = $this->getCloneUrl()) ? (string) $url : null, | ||||
|       'created_at' => ($date = $this->getCreatedAt()) ? $date->format('c') : null, | ||||
|       'default_branch' => $this->getDefaultBranch(), | ||||
|       'description' => $this->getDescription(), | ||||
|       'empty' => $this->isEmpty(), | ||||
|       'fork' => $this->isFork(), | ||||
|       'forks_count' => $this->getForksCount(), | ||||
|       'full_name' => $this->getFullName(), | ||||
|       'html_url' => ($url = $this->getHtmlUrl()) ? (string) $url : null, | ||||
|       'id' => $this->getId(), | ||||
|       'mirror' => $this->isMirror(), | ||||
|       'name' => $this->getName(), | ||||
|       'open_issues_count' => $this->getOpenIssuesCount(), | ||||
|       'owner' => ($user = $this->getOwner()) ? $user->jsonSerialize() : null, | ||||
|       'parent' => ($repository = $this->getParent()) ? $repository->jsonSerialize() : null, | ||||
|       'permissions' => ($perms = $this->getPermissions()) ? $perms->jsonSerialize() : null, | ||||
|       'private' => $this->isPrivate(), | ||||
|       'size' => $this->getSize(), | ||||
|       'ssh_url' => ($url = $this->getSshUrl()) ? (string) $url : null, | ||||
|       'stars_count' => $this->getStarsCount(), | ||||
|       'updated_at' => ($date = $this->getUpdatedAt()) ? $date->format('c') : null, | ||||
|       'watchers_count' => $this->getWatchersCount(), | ||||
|       'website' => ($url = $this->getWebsite()) ? (string) $url : null, | ||||
|     ]; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the HTTP-based URL for cloning this repository. | ||||
|    * @param UriInterface|null $value The new URL for cloning this repository. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setCloneUrl(?UriInterface $value): self { | ||||
|     $this->cloneUrl = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the date the repository was created. | ||||
|    * @param \DateTime|null $value The new date of creation. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setCreatedAt(?\DateTime $value): self { | ||||
|     $this->createdAt = $value; | ||||
|     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 = max(0, $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|null $value The new Gitea URL. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setHtmlUrl(?UriInterface $value): self { | ||||
|     $this->htmlUrl = $value; | ||||
|     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 = max(0, $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|null $value The new URL for cloning this repository. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setSshUrl(?UriInterface $value): self { | ||||
|     $this->sshUrl = $value; | ||||
|     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 = max(0, $value); | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the date the repository was updated. | ||||
|    * @param \DateTime|null $value The new date of update. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setUpdatedAt(?\DateTime $value): self { | ||||
|     $this->updatedAt = $value; | ||||
|     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 = max(0, $value); | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the URL of the repository website. | ||||
|    * @param UriInterface|null $value The new repository website. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setWebsite(?UriInterface $value): self { | ||||
|     $this->website = $value; | ||||
|     return $this; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										46
									
								
								src/models/ServerVersion.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								src/models/ServerVersion.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,46 @@ | ||||
| <?php declare(strict_types=1); | ||||
| namespace Gitea\Models; | ||||
|  | ||||
| /** | ||||
|  * Wraps the version of the Gitea server. | ||||
|  */ | ||||
| class ServerVersion implements \JsonSerializable { | ||||
|  | ||||
|   /** | ||||
|    * @var string The version number. | ||||
|    */ | ||||
|   private $version; | ||||
|  | ||||
|   /** | ||||
|    * Creates a new server version. | ||||
|    * @param string $version The version number. | ||||
|    */ | ||||
|   function __construct(string $version) { | ||||
|     $this->version = $version; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Creates a new server version from the specified JSON map. | ||||
|    * @param object $map A JSON map representing a server version. | ||||
|    * @return static The instance corresponding to the specified JSON map. | ||||
|    */ | ||||
|   static function fromJson(object $map): self { | ||||
|     return new static(isset($map->version) && is_string($map->version) ? $map->version : ''); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the version number. | ||||
|    * @return string The version number. | ||||
|    */ | ||||
|   function getVersion(): string { | ||||
|     return $this->version; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Converts this object to a map in JSON format. | ||||
|    * @return \stdClass The map in JSON format corresponding to this object. | ||||
|    */ | ||||
|   function jsonSerialize(): \stdClass { | ||||
|     return (object) ['version' => $this->getVersion()]; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										36
									
								
								src/models/StatusState.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								src/models/StatusState.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,36 @@ | ||||
| <?php declare(strict_types=1); | ||||
| namespace Gitea\Models; | ||||
|  | ||||
| use Enum\{EnumTrait}; | ||||
|  | ||||
| /** | ||||
|  * Defines the state of a Gitea status. | ||||
|  */ | ||||
| final class StatusState { | ||||
|   use EnumTrait; | ||||
|  | ||||
|   /** | ||||
|    * @var string The status is an error. | ||||
|    */ | ||||
|   const ERROR = 'error'; | ||||
|  | ||||
|   /** | ||||
|    * @var string The status is a failure. | ||||
|    */ | ||||
|   const FAILURE = 'failure'; | ||||
|  | ||||
|   /** | ||||
|    * @var string The status is pending. | ||||
|    */ | ||||
|   const PENDING = 'pending'; | ||||
|  | ||||
|   /** | ||||
|    * @var string The status is a success. | ||||
|    */ | ||||
|   const SUCCESS = 'success'; | ||||
|  | ||||
|   /** | ||||
|    * @var string The status is a warning. | ||||
|    */ | ||||
|   const WARNING = 'warning'; | ||||
| } | ||||
							
								
								
									
										124
									
								
								src/models/Team.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										124
									
								
								src/models/Team.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,124 @@ | ||||
| <?php declare(strict_types=1); | ||||
| namespace Gitea\Models; | ||||
|  | ||||
| /** | ||||
|  * Represents a team in an organization. | ||||
|  */ | ||||
| class Team implements \JsonSerializable { | ||||
|  | ||||
|   /** | ||||
|    * @var string The team description. | ||||
|    */ | ||||
|   private $description = ''; | ||||
|  | ||||
|   /** | ||||
|    * @var int The team identifier. | ||||
|    */ | ||||
|   private $id; | ||||
|  | ||||
|   /** | ||||
|    * @var string The team name. | ||||
|    */ | ||||
|   private $name; | ||||
|  | ||||
|   /** | ||||
|    * @var string The team permission. | ||||
|    */ | ||||
|   private $permission = TeamPermission::NONE; | ||||
|  | ||||
|   /** | ||||
|    * Creates a new team. | ||||
|    * @param int $id The team identifier. | ||||
|    * @param string $name The team name. | ||||
|    */ | ||||
|   function __construct(int $id, string $name) { | ||||
|     $this->id = $id; | ||||
|     $this->setName($name); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Creates a new user from the specified JSON map. | ||||
|    * @param object $map A JSON map representing a user. | ||||
|    * @return static The instance corresponding to the specified JSON map. | ||||
|    */ | ||||
|   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 : '')) | ||||
|       ->setDescription(isset($map->description) && is_string($map->description) ? $map->description : '') | ||||
|       ->setPermission(isset($map->permission) && is_string($map->permission) ? $map->permission : TeamPermission::NONE); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the team description. | ||||
|    * @return string The team description. | ||||
|    */ | ||||
|   function getDescription(): string { | ||||
|     return $this->description; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the team identifier. | ||||
|    * @return int The team identifier. | ||||
|    */ | ||||
|   function getId(): int { | ||||
|     return $this->id; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the team name. | ||||
|    * @return string The team name. | ||||
|    */ | ||||
|   function getName(): string { | ||||
|     return $this->name; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the team permission. | ||||
|    * @return string The team permission. | ||||
|    */ | ||||
|   function getPermission(): string { | ||||
|     return $this->permission; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Converts this object to a map in JSON format. | ||||
|    * @return \stdClass The map in JSON format corresponding to this object. | ||||
|    */ | ||||
|   function jsonSerialize(): \stdClass { | ||||
|     return (object) [ | ||||
|       'description' => $this->getDescription(), | ||||
|       'id' => $this->getId(), | ||||
|       'name' => $this->getName(), | ||||
|       'permission' => $this->getPermission() | ||||
|     ]; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the team description. | ||||
|    * @param string $value The new description. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setDescription(string $value): self { | ||||
|     $this->description = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the team name. | ||||
|    * @param string $value The new name. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setName(string $value): self { | ||||
|     $this->name = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the team permission. | ||||
|    * @param string $value The new permission. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setPermission(string $value): self { | ||||
|     $this->permission = TeamPermission::coerce($value, TeamPermission::NONE); | ||||
|     return $this; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										36
									
								
								src/models/TeamPermission.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								src/models/TeamPermission.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,36 @@ | ||||
| <?php declare(strict_types=1); | ||||
| namespace Gitea\Models; | ||||
|  | ||||
| use Enum\{EnumTrait}; | ||||
|  | ||||
| /** | ||||
|  * Defines the permission of a team. | ||||
|  */ | ||||
| final class TeamPermission { | ||||
|   use EnumTrait; | ||||
|  | ||||
|   /** | ||||
|    * @var string The team has the administrator permission. | ||||
|    */ | ||||
|   const ADMIN = 'admin'; | ||||
|  | ||||
|   /** | ||||
|    * @var string The team doesn't have any permission. | ||||
|    */ | ||||
|   const NONE = 'none'; | ||||
|  | ||||
|   /** | ||||
|    * @var string The team has the owner permission. | ||||
|    */ | ||||
|   const OWNER = 'owner'; | ||||
|  | ||||
|   /** | ||||
|    * @var string The team has the read permission. | ||||
|    */ | ||||
|   const READ = 'read'; | ||||
|  | ||||
|   /** | ||||
|    * @var string The team has the write permission. | ||||
|    */ | ||||
|   const WRITE = 'write'; | ||||
| } | ||||
							
								
								
									
										149
									
								
								src/models/TrackedTime.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										149
									
								
								src/models/TrackedTime.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,149 @@ | ||||
| <?php declare(strict_types=1); | ||||
| namespace Gitea\Models; | ||||
|  | ||||
| /** | ||||
|  * Represents the worked time for an issue or pull request. | ||||
|  */ | ||||
| class TrackedTime implements \JsonSerializable { | ||||
|  | ||||
|   /** | ||||
|    * @var \DateTime|null The date the entry was created. | ||||
|    */ | ||||
|   private $createdAt; | ||||
|  | ||||
|   /** | ||||
|    * @var int The entry identifier. | ||||
|    */ | ||||
|   private $id; | ||||
|  | ||||
|   /** | ||||
|    * @var int The identifier of the associated issue or pull request. | ||||
|    */ | ||||
|   private $issueId = -1; | ||||
|  | ||||
|   /** | ||||
|    * @var int The elapsed time, in seconds. | ||||
|    */ | ||||
|   private $time; | ||||
|  | ||||
|   /** | ||||
|    * @var int The identifier of the initiating user. | ||||
|    */ | ||||
|   private $userId = -1; | ||||
|  | ||||
|   /** | ||||
|    * Creates a new entry. | ||||
|    * @param int $id The entry identifier. | ||||
|    * @param int $time The elapsed time, in seconds. | ||||
|    */ | ||||
|   function __construct(int $id, int $time) { | ||||
|     $this->id = $id; | ||||
|     $this->setTime($time); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Creates a new entry from the specified JSON map. | ||||
|    * @param object $map A JSON map representing an entry. | ||||
|    * @return static The instance corresponding to the specified JSON map. | ||||
|    */ | ||||
|   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)) | ||||
|       ->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) | ||||
|       ->setUserId(isset($map->user_id) && is_int($map->user_id) ? $map->user_id : -1); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the date the entry was created. | ||||
|    * @return \DateTime|null The date the entry was created. | ||||
|    */ | ||||
|   function getCreatedAt(): ?\DateTime { | ||||
|     return $this->createdAt; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the entry identifier. | ||||
|    * @return int The entry identifier. | ||||
|    */ | ||||
|   function getId(): int { | ||||
|     return $this->id; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the identifier of the associated issue or pull request. | ||||
|    * @return int The identifier of the associated issue or pull request. | ||||
|    */ | ||||
|   function getIssueId(): int { | ||||
|     return $this->issueId; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the elapsed time, in seconds. | ||||
|    * @return int The elapsed time, in seconds. | ||||
|    */ | ||||
|   function getTime(): int { | ||||
|     return $this->time; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the identifier of the initiating user. | ||||
|    * @return int The identifier of the initiating user. | ||||
|    */ | ||||
|   function getUserId(): int { | ||||
|     return $this->userId; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Converts this object to a map in JSON format. | ||||
|    * @return \stdClass The map in JSON format corresponding to this object. | ||||
|    */ | ||||
|   function jsonSerialize(): \stdClass { | ||||
|     return (object) [ | ||||
|       'created' => ($date = $this->getCreatedAt()) ? $date->format('c') : null, | ||||
|       'id' => $this->getId(), | ||||
|       'issue_id' => $this->getIssueId(), | ||||
|       'time' => $this->getTime(), | ||||
|       'user_id' => $this->getUserId() | ||||
|     ]; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the date the entry was created. | ||||
|    * @param \DateTime|null $value The new date of creation. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setCreatedAt(?\DateTime $value): self { | ||||
|     $this->createdAt = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the identifier of the associated issue or pull request. | ||||
|    * @param int $value The new issue identifier. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setIssueId(int $value): self { | ||||
|     $this->issueId = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the elapsed time, in seconds. | ||||
|    * @param int $value The new elapsed time, in seconds. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setTime(int $value): self { | ||||
|     $this->time = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the identifier of the initiating user. | ||||
|    * @param int $value The new user identifier. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setUserId(int $value): self { | ||||
|     $this->userId = $value; | ||||
|     return $this; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										177
									
								
								src/models/User.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										177
									
								
								src/models/User.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,177 @@ | ||||
| <?php declare(strict_types=1); | ||||
| namespace Gitea\Models; | ||||
|  | ||||
| use GuzzleHttp\Psr7\{Uri}; | ||||
| use Psr\Http\Message\{UriInterface}; | ||||
|  | ||||
| /** | ||||
|  * Represents a Gitea user. | ||||
|  */ | ||||
| class User implements \JsonSerializable { | ||||
|  | ||||
|   /** | ||||
|    * @var UriInterface|null The URL to the user's avatar. | ||||
|    */ | ||||
|   private $avatarUrl; | ||||
|  | ||||
|   /** | ||||
|    * @var string The mail address. | ||||
|    */ | ||||
|   private $email = ''; | ||||
|  | ||||
|   /** | ||||
|    * @var string The full name. | ||||
|    */ | ||||
|   private $fullName = ''; | ||||
|  | ||||
|   /** | ||||
|    * @var int The user identifier. | ||||
|    */ | ||||
|   private $id; | ||||
|  | ||||
|   /** | ||||
|    * @var string The user locale. | ||||
|    */ | ||||
|   private $language = ''; | ||||
|  | ||||
|   /** | ||||
|    * @var string The name of the Gitea account. | ||||
|    */ | ||||
|   private $login; | ||||
|  | ||||
|   /** | ||||
|    * Creates a new user. | ||||
|    * @param int $id The user identifier. | ||||
|    * @param string $login The name of the Gitea account. | ||||
|    */ | ||||
|   function __construct(int $id, string $login) { | ||||
|     $this->id = $id; | ||||
|     $this->setLogin($login); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Creates a new user from the specified JSON map. | ||||
|    * @param object $map A JSON map representing a user. | ||||
|    * @return static The instance corresponding to the specified JSON map. | ||||
|    */ | ||||
|   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 : '')) | ||||
|       ->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) : '') | ||||
|       ->setFullName(isset($map->full_name) && is_string($map->full_name) ? $map->full_name : '') | ||||
|       ->setLanguage(isset($map->language) && is_string($map->language) ? $map->language : ''); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the URL of the avatar image. | ||||
|    * @return UriInterface|null The URL of the avatar image. | ||||
|    */ | ||||
|   function getAvatarUrl(): ?UriInterface { | ||||
|     return $this->avatarUrl; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * 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 getFullName(): string { | ||||
|     return $this->fullName; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the user identifier. | ||||
|    * @return int The user identifier. | ||||
|    */ | ||||
|   function getId(): int { | ||||
|     return $this->id; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the user locale. | ||||
|    * @return string The user locale. | ||||
|    */ | ||||
|   function getLanguage(): string { | ||||
|     return $this->language; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Gets the name of the Gitea account. | ||||
|    * @return string The name of the Gitea account. | ||||
|    */ | ||||
|   function getLogin(): string { | ||||
|     return $this->login; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Converts this object to a map in JSON format. | ||||
|    * @return \stdClass The map in JSON format corresponding to this object. | ||||
|    */ | ||||
|   function jsonSerialize(): \stdClass { | ||||
|     return (object) [ | ||||
|       'avatar_url' => ($url = $this->getAvatarUrl()) ? (string) $url : null, | ||||
|       'email' => $this->getEmail(), | ||||
|       'full_name' => $this->getFullName(), | ||||
|       'id' => $this->getId(), | ||||
|       'language' => $this->getLanguage(), | ||||
|       'login' => $this->getLogin() | ||||
|     ]; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the URL of the avatar image. | ||||
|    * @param UriInterface|null $value The new avatar URL. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setAvatarUrl(?UriInterface $value): self { | ||||
|     $this->avatarUrl = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * 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 setFullName(string $value): self { | ||||
|     $this->fullName = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the user locale. | ||||
|    * @param string $value The new user locale. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setLanguage(string $value): self { | ||||
|     $this->language = $value; | ||||
|     return $this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Sets the name of the Gitea account. | ||||
|    * @param string $value The new Gitea account. | ||||
|    * @return $this This instance. | ||||
|    */ | ||||
|   function setLogin(string $value): self { | ||||
|     $this->login = $value; | ||||
|     return $this; | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user