mirror of
				https://github.com/sitelease/sugar-cube-client.git
				synced 2025-10-31 12:02:30 +01:00 
			
		
		
		
	Compare commits
	
		
			2 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 5c22c6fcee | |||
| 70fb0b15d8 | 
| @ -1,8 +1,9 @@ | |||||||
| # https://editorconfig.org | # https://editorconfig.org | ||||||
| root = true | root = true | ||||||
|  |  | ||||||
| [*.php] | [*] | ||||||
| charset = utf-8 | charset = utf-8 | ||||||
|  | end_of_line = lf | ||||||
| indent_size = 4 | indent_size = 4 | ||||||
| indent_style = space | indent_style = space | ||||||
| insert_final_newline = true | insert_final_newline = true | ||||||
|  | |||||||
							
								
								
									
										12
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							| @ -1,17 +1,5 @@ | |||||||
| * text=auto | * text=auto | ||||||
|  |  | ||||||
| .* text |  | ||||||
| *.http text |  | ||||||
| *.info text |  | ||||||
| *.json text |  | ||||||
| *.md text |  | ||||||
| *.neon text |  | ||||||
| *.php text diff=php |  | ||||||
| *.txt text |  | ||||||
| *.xml text |  | ||||||
| *.yml text |  | ||||||
| *.yaml text |  | ||||||
|  |  | ||||||
| *.ico binary | *.ico binary | ||||||
| *.jpg binary | *.jpg binary | ||||||
| *.pdf binary | *.pdf binary | ||||||
|  | |||||||
							
								
								
									
										10
									
								
								.phpcs.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								.phpcs.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | |||||||
|  | <?xml version="1.0"?> | ||||||
|  | <ruleset name="SLPSR12" namespace="Sitelease\OpenCore"> | ||||||
|  |     <description>Sitelease's augmented PSR-12 standard</description> | ||||||
|  |     <rule ref="PSR12"> | ||||||
|  |         <exclude name="PSR12.Files.FileHeader" /> | ||||||
|  |         <exclude name="Squiz.WhiteSpace.OperatorSpacing" /> | ||||||
|  |         <exclude name="PSR12.Operators.OperatorSpacing" /> | ||||||
|  |         <exclude name="PSR2.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace"/> | ||||||
|  |     </rule> | ||||||
|  | </ruleset> | ||||||
| @ -2,11 +2,9 @@ | |||||||
|  |  | ||||||
| namespace Gitea\Api\Abstracts; | namespace Gitea\Api\Abstracts; | ||||||
|  |  | ||||||
| use GuzzleHttp\Exception\ServerException; |  | ||||||
|  |  | ||||||
| use Gitea\Client; | use Gitea\Client; | ||||||
|  | use GuzzleHttp\Exception\ServerException; | ||||||
| use Gitea\Collections\ApiItemCollection; | use Gitea\Collections\ApiItemCollection; | ||||||
|  |  | ||||||
| use Gitea\Api\Abstracts\AbstractApiRequester; | use Gitea\Api\Abstracts\AbstractApiRequester; | ||||||
| use Gitea\Api\Interfaces\AllRequesterInterface; | use Gitea\Api\Interfaces\AllRequesterInterface; | ||||||
|  |  | ||||||
| @ -43,7 +41,8 @@ abstract class AbstractAllApiRequester extends AbstractApiRequester implements A | |||||||
|      * @param array $extraOptions An array of extra options to pass the API reoute |      * @param array $extraOptions An array of extra options to pass the API reoute | ||||||
|      * @return ApiItemCollection |      * @return ApiItemCollection | ||||||
|      */ |      */ | ||||||
|     public function getPageOfAllItems(int $page = 1, int $limit = null, array $extraOptions = array()) { |     public function getPageOfAllItems(int $page = 1, int $limit = null, array $extraOptions = array()) | ||||||
|  |     { | ||||||
|         trigger_error("The abstract 'requestAllItems()' method must be overwritten"); |         trigger_error("The abstract 'requestAllItems()' method must be overwritten"); | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| @ -61,7 +60,7 @@ abstract class AbstractAllApiRequester extends AbstractApiRequester implements A | |||||||
|         $maxPageCount = $this->getMaxPageCount(); |         $maxPageCount = $this->getMaxPageCount(); | ||||||
|         $itemsPerPage = $this->getItemsPerPage(); |         $itemsPerPage = $this->getItemsPerPage(); | ||||||
|         // Loop over pages until the $maxPageCount is reached |         // Loop over pages until the $maxPageCount is reached | ||||||
|         for ($pageNum=1; $pageNum < $maxPageCount; $pageNum++) { |         for ($pageNum = 1; $pageNum < $maxPageCount; $pageNum++) { | ||||||
|             $searchItemsCollection = $this->getPageOfAllItems($pageNum, $itemsPerPage); |             $searchItemsCollection = $this->getPageOfAllItems($pageNum, $itemsPerPage); | ||||||
|             if ($searchItemsCollection && $searchItemsCollection->count() > 0) { |             if ($searchItemsCollection && $searchItemsCollection->count() > 0) { | ||||||
|                 $searchItemsArray = $searchItemsCollection->toArray(); |                 $searchItemsArray = $searchItemsCollection->toArray(); | ||||||
| @ -73,12 +72,13 @@ abstract class AbstractAllApiRequester extends AbstractApiRequester implements A | |||||||
|         return new ApiItemCollection($allItems); |         return new ApiItemCollection($allItems); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getMaxPageCount() { |     public function getMaxPageCount() | ||||||
|  |     { | ||||||
|         return $this->maxPageCount; |         return $this->maxPageCount; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getItemsPerPage() { |     public function getItemsPerPage() | ||||||
|  |     { | ||||||
|         return $this->itemsPerPage; |         return $this->itemsPerPage; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -7,6 +7,7 @@ use Gitea\Client; | |||||||
| // Traits | // Traits | ||||||
| use Gitea\Core\Traits\RequestChainable; | use Gitea\Core\Traits\RequestChainable; | ||||||
|  |  | ||||||
|  | // Interfaces | ||||||
| use Gitea\Api\Interfaces\ApiRequesterInterface; | use Gitea\Api\Interfaces\ApiRequesterInterface; | ||||||
| use Gitea\Core\Interfaces\RequestChainableInterface; | use Gitea\Core\Interfaces\RequestChainableInterface; | ||||||
|  |  | ||||||
| @ -120,7 +121,8 @@ abstract class AbstractApiRequester implements ApiRequesterInterface, RequestCha | |||||||
|      * |      * | ||||||
|      * @return Client |      * @return Client | ||||||
|      */ |      */ | ||||||
|     public function getClient(): Client { |     public function getClient(): Client | ||||||
|  |     { | ||||||
|         return $this->client; |         return $this->client; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -131,7 +133,8 @@ abstract class AbstractApiRequester implements ApiRequesterInterface, RequestCha | |||||||
|      * @param Client $client |      * @param Client $client | ||||||
|      * @return self |      * @return self | ||||||
|      */ |      */ | ||||||
|     public function setClient(Client &$client) { |     public function setClient(Client &$client) | ||||||
|  |     { | ||||||
|         $this->client = $client; |         $this->client = $client; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -143,7 +146,8 @@ abstract class AbstractApiRequester implements ApiRequesterInterface, RequestCha | |||||||
|      * |      * | ||||||
|      * @return string |      * @return string | ||||||
|      */ |      */ | ||||||
|     public function getAuthToken(): string { |     public function getAuthToken(): string | ||||||
|  |     { | ||||||
|         return $this->authToken; |         return $this->authToken; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -154,7 +158,8 @@ abstract class AbstractApiRequester implements ApiRequesterInterface, RequestCha | |||||||
|      * @param string $authToken |      * @param string $authToken | ||||||
|      * @return self |      * @return self | ||||||
|      */ |      */ | ||||||
|     public function setAuthToken(string $authToken) { |     public function setAuthToken(string $authToken) | ||||||
|  |     { | ||||||
|         $this->authToken = $authToken; |         $this->authToken = $authToken; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -170,7 +175,8 @@ abstract class AbstractApiRequester implements ApiRequesterInterface, RequestCha | |||||||
|      * @param string $type The type of request ("all","get","post","put",etc.) |      * @param string $type The type of request ("all","get","post","put",etc.) | ||||||
|      * @return array |      * @return array | ||||||
|      */ |      */ | ||||||
|     public function getDefaultParametersForType($type = "all") { |     public function getDefaultParametersForType($type = "all") | ||||||
|  |     { | ||||||
|         if (!$type || $type == "all") { |         if (!$type || $type == "all") { | ||||||
|             return $this->defaultParameters; |             return $this->defaultParameters; | ||||||
|         } else { |         } else { | ||||||
| @ -194,7 +200,8 @@ abstract class AbstractApiRequester implements ApiRequesterInterface, RequestCha | |||||||
|      * @param string $type The type of request ("all", "get","post","put",etc.) |      * @param string $type The type of request ("all", "get","post","put",etc.) | ||||||
|      * @return array |      * @return array | ||||||
|      */ |      */ | ||||||
|     public function getDefaultHeadersForType($type = "all") { |     public function getDefaultHeadersForType($type = "all") | ||||||
|  |     { | ||||||
|         if (!$type || $type == "all") { |         if (!$type || $type == "all") { | ||||||
|             return $this->defaultHeaders; |             return $this->defaultHeaders; | ||||||
|         } else { |         } else { | ||||||
|  | |||||||
| @ -59,5 +59,4 @@ class Branches extends AbstractApiRequester | |||||||
|             return $repositoryCollection; |             return $repositoryCollection; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -37,7 +37,7 @@ interface AllRequesterInterface | |||||||
|      * |      * | ||||||
|      * @param integer $page The page of items to return |      * @param integer $page The page of items to return | ||||||
|      * @param integer $limit Maximum number of items per page |      * @param integer $limit Maximum number of items per page | ||||||
|      * @param array $extraOptions An array of extra options to pass the API reoute |      * @param array $extraOptions An array of extra options to pass the API route | ||||||
|      * @return ApiItemCollection |      * @return ApiItemCollection | ||||||
|      */ |      */ | ||||||
|     public function getPageOfAllItems(int $page = 1, int $limit = null, array $extraOptions = array()); |     public function getPageOfAllItems(int $page = 1, int $limit = null, array $extraOptions = array()); | ||||||
|  | |||||||
| @ -61,7 +61,7 @@ interface ApiRequesterInterface | |||||||
|     public function configure(); |     public function configure(); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Send a GET request using an underlying reqest library |      * Send a GET request using an underlying request library | ||||||
|      * |      * | ||||||
|      * @param string $path |      * @param string $path | ||||||
|      * @param array $parameters |      * @param array $parameters | ||||||
| @ -72,7 +72,7 @@ interface ApiRequesterInterface | |||||||
|     public function get($path, array $parameters = array(), $requestHeaders = array(), $debugRequest = false); |     public function get($path, array $parameters = array(), $requestHeaders = array(), $debugRequest = false); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Send a POST request using an underlying reqest library |      * Send a POST request using an underlying request library | ||||||
|      * |      * | ||||||
|      * @param string $path |      * @param string $path | ||||||
|      * @param array $body |      * @param array $body | ||||||
| @ -83,7 +83,7 @@ interface ApiRequesterInterface | |||||||
|     public function post($path, $body, $requestHeaders = array(), $debugRequest = false); |     public function post($path, $body, $requestHeaders = array(), $debugRequest = false); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Send a PUT request using an underlying reqest library |      * Send a PUT request using an underlying request library | ||||||
|      * |      * | ||||||
|      * @param string $path |      * @param string $path | ||||||
|      * @param array $body |      * @param array $body | ||||||
| @ -94,7 +94,7 @@ interface ApiRequesterInterface | |||||||
|     public function put($path, $body, $requestHeaders = array(), $debugRequest = false); |     public function put($path, $body, $requestHeaders = array(), $debugRequest = false); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Send a DELETE request using an underlying reqest library |      * Send a DELETE request using an underlying request library | ||||||
|      * |      * | ||||||
|      * @param string $path |      * @param string $path | ||||||
|      * @param array $requestHeaders |      * @param array $requestHeaders | ||||||
|  | |||||||
| @ -7,11 +7,11 @@ use GuzzleHttp\Psr7\Response; | |||||||
| use Gitea\Client; | use Gitea\Client; | ||||||
| use Gitea\Model\Organization; | use Gitea\Model\Organization; | ||||||
|  |  | ||||||
|  | use GuzzleHttp\Exception\ServerException; | ||||||
| use Gitea\Api\Abstracts\AbstractApiRequester; | use Gitea\Api\Abstracts\AbstractApiRequester; | ||||||
|  |  | ||||||
| class Organizations extends AbstractApiRequester | class Organizations extends AbstractApiRequester | ||||||
| { | { | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Get an organization using its username and parse |      * Get an organization using its username and parse | ||||||
|      * it's information into an organization object |      * it's information into an organization object | ||||||
| @ -42,5 +42,4 @@ class Organizations extends AbstractApiRequester | |||||||
|             return $response; |             return $response; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -23,7 +23,8 @@ class Repositories extends AbstractAllApiRequester | |||||||
|      * @param array $extraOptions An array of extra options to pass the API reoute |      * @param array $extraOptions An array of extra options to pass the API reoute | ||||||
|      * @return ApiItemCollection |      * @return ApiItemCollection | ||||||
|      */ |      */ | ||||||
|     public function getPageOfAllItems(int $page = 1, int $limit = null, array $extraOptions = array()) { |     public function getPageOfAllItems(int $page = 1, int $limit = null, array $extraOptions = array()) | ||||||
|  |     { | ||||||
|         return $this->search("", $page, $limit, $extraOptions); |         return $this->search("", $page, $limit, $extraOptions); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -48,7 +49,7 @@ class Repositories extends AbstractAllApiRequester | |||||||
|  |  | ||||||
|         $repositoryCollection = new ApiItemCollection(); |         $repositoryCollection = new ApiItemCollection(); | ||||||
|         try { |         try { | ||||||
|             $response = $this->get("repos/search",[ |             $response = $this->get("repos/search", [ | ||||||
|                 "page" => $page, |                 "page" => $page, | ||||||
|                 "limit" => $limit |                 "limit" => $limit | ||||||
|             ]); |             ]); | ||||||
| @ -72,7 +73,6 @@ class Repositories extends AbstractAllApiRequester | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             return $repositoryCollection; |             return $repositoryCollection; | ||||||
|  |  | ||||||
|         } catch (ServerException $serverError) { |         } catch (ServerException $serverError) { | ||||||
|             return $repositoryCollection; |             return $repositoryCollection; | ||||||
|         } |         } | ||||||
| @ -105,7 +105,6 @@ class Repositories extends AbstractAllApiRequester | |||||||
|                 ); |                 ); | ||||||
|             } |             } | ||||||
|             return false; |             return false; | ||||||
|  |  | ||||||
|         } catch (ServerException $serverError) { |         } catch (ServerException $serverError) { | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
| @ -137,7 +136,6 @@ class Repositories extends AbstractAllApiRequester | |||||||
|                 ); |                 ); | ||||||
|             } |             } | ||||||
|             return false; |             return false; | ||||||
|  |  | ||||||
|         } catch (ServerException $serverError) { |         } catch (ServerException $serverError) { | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
| @ -158,12 +156,12 @@ class Repositories extends AbstractAllApiRequester | |||||||
|      * @param string $ref The name of the commit/branch/tag. Default the repository’s default branch (usually master) |      * @param string $ref The name of the commit/branch/tag. Default the repository’s default branch (usually master) | ||||||
|      * @return string |      * @return string | ||||||
|      */ |      */ | ||||||
|     public function getFileContents(string $owner, string $repoName, string $filepath, string $ref="") |     public function getFileContents(string $owner, string $repoName, string $filepath, string $ref = "") | ||||||
|     { |     { | ||||||
|         $client = $this->getClient(); |         $client = $this->getClient(); | ||||||
|         try { |         try { | ||||||
|             if ($ref !== "") { |             if ($ref !== "") { | ||||||
|                 $response = $this->get("repos/$owner/$repoName/contents/$filepath",[ |                 $response = $this->get("repos/$owner/$repoName/contents/$filepath", [ | ||||||
|                     "ref" => $ref |                     "ref" => $ref | ||||||
|                 ]); |                 ]); | ||||||
|             } else { |             } else { | ||||||
| @ -181,7 +179,6 @@ class Repositories extends AbstractAllApiRequester | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             return false; |             return false; | ||||||
|  |  | ||||||
|         } catch (ServerException $serverError) { |         } catch (ServerException $serverError) { | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
| @ -213,10 +210,8 @@ class Repositories extends AbstractAllApiRequester | |||||||
|                 return $body; |                 return $body; | ||||||
|             } |             } | ||||||
|             return false; |             return false; | ||||||
|  |  | ||||||
|         } catch (ServerException $serverError) { |         } catch (ServerException $serverError) { | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -59,5 +59,4 @@ class Tags extends AbstractApiRequester | |||||||
|             return $repositoryCollection; |             return $repositoryCollection; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -46,7 +46,7 @@ class Client implements RequestChainableInterface | |||||||
|     /** |     /** | ||||||
|      * The secret for the push notifications system |      * The secret for the push notifications system | ||||||
|      * |      * | ||||||
|      * Used to varify incoming push notifications |      * Used to verify incoming push notifications | ||||||
|      * are from your Gitea server |      * are from your Gitea server | ||||||
|      * |      * | ||||||
|      * @var string |      * @var string | ||||||
| @ -59,8 +59,8 @@ class Client implements RequestChainableInterface | |||||||
|      * @author Benjamin Blake (sitelease.ca) |      * @author Benjamin Blake (sitelease.ca) | ||||||
|      * |      * | ||||||
|      * @param string $giteaURL The full URL to Gitea's API route (including the version) |      * @param string $giteaURL The full URL to Gitea's API route (including the version) | ||||||
|      * @param string|null $authToken A Gitlea API auth token |      * @param string|null $authToken A Gitea API auth token | ||||||
|      * @param string|null $pushEventSecret The secret used to varify incoming push notifications |      * @param string|null $pushEventSecret The secret used to verify incoming push notifications | ||||||
|      */ |      */ | ||||||
|     public function __construct($giteaURL, $authToken = null, $pushEventSecret = null) |     public function __construct($giteaURL, $authToken = null, $pushEventSecret = null) | ||||||
|     { |     { | ||||||
| @ -98,11 +98,13 @@ class Client implements RequestChainableInterface | |||||||
|         return $this->guzzleClient; |         return $this->guzzleClient; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getAuthToken() { |     public function getAuthToken() | ||||||
|  |     { | ||||||
|         return $this->authToken; |         return $this->authToken; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function setAuthToken($value) { |     public function setAuthToken($value) | ||||||
|  |     { | ||||||
|         $this->authToken = $value; |         $this->authToken = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -133,7 +135,7 @@ class Client implements RequestChainableInterface | |||||||
|      * @param string $needle |      * @param string $needle | ||||||
|      * @return boolean |      * @return boolean | ||||||
|      */ |      */ | ||||||
|     function endsWith($haystack, $needle) |     public function endsWith($haystack, $needle) | ||||||
|     { |     { | ||||||
|         return substr($haystack, -strlen($needle))===$needle; |         return substr($haystack, -strlen($needle))===$needle; | ||||||
|     } |     } | ||||||
| @ -147,7 +149,8 @@ class Client implements RequestChainableInterface | |||||||
|      * |      * | ||||||
|      * @return boolean |      * @return boolean | ||||||
|      */ |      */ | ||||||
|     public function checkAuthToken($softErrors = false) { |     public function checkAuthToken($softErrors = false) | ||||||
|  |     { | ||||||
|         $authToken = $this->authToken; |         $authToken = $this->authToken; | ||||||
|         if (!$authToken) { |         if (!$authToken) { | ||||||
|             if ($softErrors) { |             if ($softErrors) { | ||||||
| @ -217,5 +220,4 @@ class Client implements RequestChainableInterface | |||||||
|     { |     { | ||||||
|         return new Organizations($this, $this); |         return new Organizations($this, $this); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -4,25 +4,26 @@ namespace Gitea\Collections; | |||||||
|  |  | ||||||
| use Gitea\Collections\Interfaces\ApiCollectionInterface; | use Gitea\Collections\Interfaces\ApiCollectionInterface; | ||||||
|  |  | ||||||
| use \Countable; | use Countable; | ||||||
| use \IteratorAggregate; | use IteratorAggregate; | ||||||
| use \ArrayIterator; | use ArrayIterator; | ||||||
|  |  | ||||||
| class ApiItemCollection implements ApiCollectionInterface, IteratorAggregate, Countable | class ApiItemCollection implements ApiCollectionInterface, IteratorAggregate, Countable | ||||||
| { | { | ||||||
|     private $items = array(); |     private $items = array(); | ||||||
|  |  | ||||||
|     public function __construct($internalArray = array()) { |     public function __construct($internalArray = array()) | ||||||
|  |     { | ||||||
|         if ($internalArray && is_array($internalArray)) { |         if ($internalArray && is_array($internalArray)) { | ||||||
|             $this->items = $internalArray; |             $this->items = $internalArray; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function addItem($apiObject, $key = null) { |     public function addItem($apiObject, $key = null) | ||||||
|  |     { | ||||||
|         if ($key == null) { |         if ($key == null) { | ||||||
|             $this->items[] = $apiObject; |             $this->items[] = $apiObject; | ||||||
|         } |         } else { | ||||||
|         else { |  | ||||||
|             if (isset($this->items[$key])) { |             if (isset($this->items[$key])) { | ||||||
|                 return false; |                 return false; | ||||||
|             } else { |             } else { | ||||||
| @ -31,7 +32,8 @@ class ApiItemCollection implements ApiCollectionInterface, IteratorAggregate, Co | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function deleteItem($key) { |     public function deleteItem($key) | ||||||
|  |     { | ||||||
|         if (isset($this->items[$key])) { |         if (isset($this->items[$key])) { | ||||||
|             unset($this->items[$key]); |             unset($this->items[$key]); | ||||||
|         } else { |         } else { | ||||||
| @ -39,7 +41,8 @@ class ApiItemCollection implements ApiCollectionInterface, IteratorAggregate, Co | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getItem($key) { |     public function getItem($key) | ||||||
|  |     { | ||||||
|         if (isset($this->items[$key])) { |         if (isset($this->items[$key])) { | ||||||
|             return $this->items[$key]; |             return $this->items[$key]; | ||||||
|         } else { |         } else { | ||||||
| @ -47,23 +50,28 @@ class ApiItemCollection implements ApiCollectionInterface, IteratorAggregate, Co | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function keys() { |     public function keys() | ||||||
|  |     { | ||||||
|         return array_keys($this->items); |         return array_keys($this->items); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function count() { |     public function count() | ||||||
|  |     { | ||||||
|         return count($this->items); |         return count($this->items); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function keyExists($key) { |     public function keyExists($key) | ||||||
|  |     { | ||||||
|         return isset($this->items[$key]); |         return isset($this->items[$key]); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function toArray() { |     public function toArray() | ||||||
|  |     { | ||||||
|         return $this->items; |         return $this->items; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getIterator() { |     public function getIterator() | ||||||
|  |     { | ||||||
|         return new ArrayIterator($this->items); |         return new ArrayIterator($this->items); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -6,7 +6,7 @@ use Gitea\Client; | |||||||
| use Gitea\Model\Repository; | use Gitea\Model\Repository; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Interface that allows the tracking of request heirarchies |  * Interface that allows the tracking of request hierarchies | ||||||
|  * |  * | ||||||
|  * @author Benjamin Blake (sitelease.ca) |  * @author Benjamin Blake (sitelease.ca) | ||||||
|  */ |  */ | ||||||
| @ -31,7 +31,7 @@ interface RequestChainableInterface | |||||||
|     public function setCaller(?object $object); |     public function setCaller(?object $object); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Return the request chain heirarchy |      * Return the request chain hierarchy | ||||||
|      * as an array of objects |      * as an array of objects | ||||||
|      * |      * | ||||||
|      * This is useful if you need to know |      * This is useful if you need to know | ||||||
| @ -58,11 +58,11 @@ interface RequestChainableInterface | |||||||
|     public function searchRequestChain(string $class): ?object; |     public function searchRequestChain(string $class): ?object; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Return the request chain heirarchy |      * Return the request chain hierarchy | ||||||
|      * as a string of class names |      * as a string of class names | ||||||
|      * |      * | ||||||
|      * This is useful if you need to quickly print out |      * This is useful if you need to quickly print out | ||||||
|      * a breadcrumb like heirarchy of callers |      * a breadcrumb like hierarchy of callers | ||||||
|      * |      * | ||||||
|      * @author Benjamin Blake (sitelease.ca) |      * @author Benjamin Blake (sitelease.ca) | ||||||
|      * @return array |      * @return array | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ trait RequestChainable | |||||||
|     /** |     /** | ||||||
|      * The object that called this object |      * The object that called this object | ||||||
|      * |      * | ||||||
|      * @var string |      * @var object | ||||||
|      */ |      */ | ||||||
|     private $caller; |     private $caller; | ||||||
|  |  | ||||||
| @ -47,7 +47,7 @@ trait RequestChainable | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Return the request chain heirarchy |      * Return the request chain hierarchy | ||||||
|      * as an array of objects |      * as an array of objects | ||||||
|      * |      * | ||||||
|      * This is useful if you need to know |      * This is useful if you need to know | ||||||
| @ -103,11 +103,11 @@ trait RequestChainable | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Return the request chain heirarchy |      * Return the request chain hierarchy | ||||||
|      * as a string of class names |      * as a string of class names | ||||||
|      * |      * | ||||||
|      * This is useful if you need to quickly print out |      * This is useful if you need to quickly print out | ||||||
|      * a breadcrumb like heirarchy of callers |      * a breadcrumb like hierarchy of callers | ||||||
|      * |      * | ||||||
|      * @author Benjamin Blake (sitelease.ca) |      * @author Benjamin Blake (sitelease.ca) | ||||||
|      * @return array |      * @return array | ||||||
| @ -151,5 +151,4 @@ trait RequestChainable | |||||||
|  |  | ||||||
|         return $repository; |         return $repository; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -5,8 +5,8 @@ namespace Gitea\Model\Abstracts; | |||||||
| use Gitea\Client; | use Gitea\Client; | ||||||
| use Gitea\Api\Interfaces\ApiRequesterInterface; | use Gitea\Api\Interfaces\ApiRequesterInterface; | ||||||
|  |  | ||||||
| use \stdClass; | use stdClass; | ||||||
| use \JsonSerializable; | use JsonSerializable; | ||||||
|  |  | ||||||
| // Traits | // Traits | ||||||
| use Gitea\Core\Traits\RequestChainable; | use Gitea\Core\Traits\RequestChainable; | ||||||
| @ -16,7 +16,6 @@ use Gitea\Core\Interfaces\RequestChainableInterface; | |||||||
|  |  | ||||||
| abstract class AbstractApiModel implements ApiModelInterface, JsonSerializable, RequestChainableInterface | abstract class AbstractApiModel implements ApiModelInterface, JsonSerializable, RequestChainableInterface | ||||||
| { | { | ||||||
|  |  | ||||||
|     use RequestChainable; |     use RequestChainable; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @ -28,7 +27,8 @@ abstract class AbstractApiModel implements ApiModelInterface, JsonSerializable, | |||||||
|      * @param object|null $caller The object that called this method |      * @param object|null $caller The object that called this method | ||||||
|      * @param mixed $args The organization visibility. |      * @param mixed $args The organization visibility. | ||||||
|      */ |      */ | ||||||
|     public function __construct(Client &$client, ?object $caller, ...$args) { |     public function __construct(Client &$client, ?object $caller, ...$args) | ||||||
|  |     { | ||||||
|         $this->setClient($client); |         $this->setClient($client); | ||||||
|         $this->setCaller($caller); |         $this->setCaller($caller); | ||||||
|     } |     } | ||||||
| @ -59,7 +59,8 @@ abstract class AbstractApiModel implements ApiModelInterface, JsonSerializable, | |||||||
|      * @param object|null $caller The object that called this method |      * @param object|null $caller The object that called this method | ||||||
|      * @param object $map A JSON data object |      * @param object $map A JSON data object | ||||||
|      */ |      */ | ||||||
|     static function fromJson(object &$client, ?object $caller, object $map) { |     public static function fromJson(object &$client, ?object $caller, object $map) | ||||||
|  |     { | ||||||
|         trigger_error("The abstract 'fromJson()' method must be overwritten"); |         trigger_error("The abstract 'fromJson()' method must be overwritten"); | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| @ -72,7 +73,8 @@ abstract class AbstractApiModel implements ApiModelInterface, JsonSerializable, | |||||||
|      * |      * | ||||||
|      * @return stdClass The map in JSON format corresponding to this object. |      * @return stdClass The map in JSON format corresponding to this object. | ||||||
|      */ |      */ | ||||||
|     public function jsonSerialize(): \stdClass { |     public function jsonSerialize(): stdClass | ||||||
|  |     { | ||||||
|         trigger_error("The abstract 'jsonSerialize()' method must be overwritten"); |         trigger_error("The abstract 'jsonSerialize()' method must be overwritten"); | ||||||
|         return self; |         return self; | ||||||
|     } |     } | ||||||
| @ -84,7 +86,8 @@ abstract class AbstractApiModel implements ApiModelInterface, JsonSerializable, | |||||||
|      * |      * | ||||||
|      * @return Client |      * @return Client | ||||||
|      */ |      */ | ||||||
|     public function getClient(): Client { |     public function getClient(): Client | ||||||
|  |     { | ||||||
|         return $this->client; |         return $this->client; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -95,7 +98,8 @@ abstract class AbstractApiModel implements ApiModelInterface, JsonSerializable, | |||||||
|      * @param Client $client |      * @param Client $client | ||||||
|      * @return self |      * @return self | ||||||
|      */ |      */ | ||||||
|     public function setClient(Client &$client) { |     public function setClient(Client &$client) | ||||||
|  |     { | ||||||
|         $this->client = $client; |         $this->client = $client; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -8,13 +8,14 @@ use Psr\Http\Message\UriInterface; | |||||||
| use Gitea\Client; | use Gitea\Client; | ||||||
| use Gitea\Model\PayloadCommit; | use Gitea\Model\PayloadCommit; | ||||||
|  |  | ||||||
| use \InvalidArgumentException; | use InvalidArgumentException; | ||||||
|  | use stdClass; | ||||||
|  |  | ||||||
| use Gitea\Model\Abstracts\AbstractApiModel; | use Gitea\Model\Abstracts\AbstractApiModel; | ||||||
|  |  | ||||||
| /** Represents a Gitea branch. */ | /** Represents a Gitea branch. */ | ||||||
| class Branch extends AbstractApiModel { | class Branch extends AbstractApiModel | ||||||
|  | { | ||||||
|     /** @var string The branch's name */ |     /** @var string The branch's name */ | ||||||
|     private $name = ''; |     private $name = ''; | ||||||
|  |  | ||||||
| @ -25,7 +26,7 @@ class Branch extends AbstractApiModel { | |||||||
|     private $protected = true; |     private $protected = true; | ||||||
|  |  | ||||||
|     /** @var string True if the user can push to this branch */ |     /** @var string True if the user can push to this branch */ | ||||||
|     private $userCanPush = false; |     private $canUserPush = false; | ||||||
|  |  | ||||||
|     /** @var string True if the user can merge this branch */ |     /** @var string True if the user can merge this branch */ | ||||||
|     private $userCanMerge = false; |     private $userCanMerge = false; | ||||||
| @ -37,7 +38,8 @@ class Branch extends AbstractApiModel { | |||||||
|      * @param object|null $caller The object that called this method |      * @param object|null $caller The object that called this method | ||||||
|      * @param string $name The branch name |      * @param string $name The branch name | ||||||
|      */ |      */ | ||||||
|     public function __construct(Client &$client , ?object $caller, ...$args) { |     public function __construct(Client &$client, ?object $caller, ...$args) | ||||||
|  |     { | ||||||
|         parent::__construct($client, $caller, $args); |         parent::__construct($client, $caller, $args); | ||||||
|         if (count($args) >= 1) { |         if (count($args) >= 1) { | ||||||
|             $name = $args[0]; |             $name = $args[0]; | ||||||
| @ -59,7 +61,8 @@ class Branch extends AbstractApiModel { | |||||||
|      * @param object $map A JSON map representing an branch. |      * @param object $map A JSON map representing an branch. | ||||||
|      * @return static The instance corresponding to the specified JSON map. |      * @return static The instance corresponding to the specified JSON map. | ||||||
|      */ |      */ | ||||||
|     static function fromJson(object &$client , ?object $caller, object $map): self { |     public static function fromJson(object &$client, ?object $caller, object $map): self | ||||||
|  |     { | ||||||
|         return ( |         return ( | ||||||
|             new static( |             new static( | ||||||
|                 $client, |                 $client, | ||||||
| @ -75,9 +78,10 @@ class Branch extends AbstractApiModel { | |||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 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 { |     public function jsonSerialize(): stdClass | ||||||
|  |     { | ||||||
|         return (object) [ |         return (object) [ | ||||||
|             'name' => $this->getName(), |             'name' => $this->getName(), | ||||||
|             'commit' => ($commit = $this->getCommit()) ? $commit->jsonSerialize() : null, |             'commit' => ($commit = $this->getCommit()) ? $commit->jsonSerialize() : null, | ||||||
| @ -87,49 +91,58 @@ class Branch extends AbstractApiModel { | |||||||
|         ]; |         ]; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getName(): string { |     public function getName(): string | ||||||
|  |     { | ||||||
|         return $this->name; |         return $this->name; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function setName(string $name): self { |     public function setName(string $name): self | ||||||
|  |     { | ||||||
|         $this->name = $name; |         $this->name = $name; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getCommit(): ?PayloadCommit { |     public function getCommit(): ?PayloadCommit | ||||||
|  |     { | ||||||
|         return $this->commit; |         return $this->commit; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function setCommit(?PayloadCommit $object): self { |     public function setCommit(?PayloadCommit $object): self | ||||||
|  |     { | ||||||
|         $this->commit = $object; |         $this->commit = $object; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getProtected() { |     public function getProtected(): bool | ||||||
|  |     { | ||||||
|         return $this->protected; |         return $this->protected; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function setProtected(bool $boolean): self { |     public function setProtected(bool $boolean): self | ||||||
|  |     { | ||||||
|         $this->protected = $boolean; |         $this->protected = $boolean; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getCanUserPush() { |     public function getCanUserPush(): bool | ||||||
|  |     { | ||||||
|         return $this->canUserPush; |         return $this->canUserPush; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function setCanUserPush(bool $boolean): self { |     public function setCanUserPush(bool $boolean): self | ||||||
|  |     { | ||||||
|         $this->canUserPush = $boolean; |         $this->canUserPush = $boolean; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getUserCanMerge() { |     public function getUserCanMerge(): bool | ||||||
|  |     { | ||||||
|         return $this->userCanMerge; |         return $this->userCanMerge; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function setUserCanMerge(bool $boolean): self { |     public function setUserCanMerge(bool $boolean): self | ||||||
|  |     { | ||||||
|         $this->userCanMerge = $boolean; |         $this->userCanMerge = $boolean; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -5,11 +5,10 @@ namespace Gitea\Model\Interfaces; | |||||||
| use Gitea\Client; | use Gitea\Client; | ||||||
| use Gitea\Api\Interfaces\ApiRequesterInterface; | use Gitea\Api\Interfaces\ApiRequesterInterface; | ||||||
|  |  | ||||||
| use \stdClass; | use stdClass; | ||||||
|  |  | ||||||
| interface ApiModelInterface | interface ApiModelInterface | ||||||
| { | { | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Creates a new API model object |      * Creates a new API model object | ||||||
|      * |      * | ||||||
| @ -39,7 +38,7 @@ interface ApiModelInterface | |||||||
|      * @param object|null $caller The object that called this method |      * @param object|null $caller The object that called this method | ||||||
|      * @param object $map A JSON data object |      * @param object $map A JSON data object | ||||||
|      */ |      */ | ||||||
|     static function fromJson(object &$client, ?object $caller, object $map); |     public static function fromJson(object &$client, ?object $caller, object $map); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Convert this Api model object to a JSON map. |      * Convert this Api model object to a JSON map. | ||||||
| @ -51,7 +50,7 @@ interface ApiModelInterface | |||||||
|      * |      * | ||||||
|      * @return stdClass The map in JSON format corresponding to this object. |      * @return stdClass The map in JSON format corresponding to this object. | ||||||
|      */ |      */ | ||||||
|     public function jsonSerialize(): \stdClass; |     public function jsonSerialize(): stdClass; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Get the gitea client (by reference) |      * Get the gitea client (by reference) | ||||||
| @ -70,5 +69,4 @@ interface ApiModelInterface | |||||||
|      * @return self |      * @return self | ||||||
|      */ |      */ | ||||||
|     public function setClient(Client &$client); |     public function setClient(Client &$client); | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -7,13 +7,14 @@ use Psr\Http\Message\UriInterface; | |||||||
|  |  | ||||||
| use Gitea\Client; | use Gitea\Client; | ||||||
|  |  | ||||||
| use \InvalidArgumentException; | use stdClass; | ||||||
|  | use InvalidArgumentException; | ||||||
|  |  | ||||||
| use Gitea\Model\Abstracts\AbstractApiModel; | use Gitea\Model\Abstracts\AbstractApiModel; | ||||||
|  |  | ||||||
| /** Represents a Gitea organization. */ | /** Represents a Gitea organization. */ | ||||||
| class Organization extends AbstractApiModel { | class Organization extends AbstractApiModel | ||||||
|  | { | ||||||
|     /** @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 = ''; | ||||||
|  |  | ||||||
| @ -45,7 +46,8 @@ class Organization extends AbstractApiModel { | |||||||
|      * @param string $username The organization name. |      * @param string $username The organization name. | ||||||
|      * @param string $visibility The organization visibility. |      * @param string $visibility The organization visibility. | ||||||
|      */ |      */ | ||||||
|     public function __construct(Client &$client , ?object $caller, ...$args) { |     public function __construct(Client &$client, ?object $caller, ...$args) | ||||||
|  |     { | ||||||
|         parent::__construct($client, $caller, $args); |         parent::__construct($client, $caller, $args); | ||||||
|         if (count($args) >= 2) { |         if (count($args) >= 2) { | ||||||
|             $username = $args[0]; |             $username = $args[0]; | ||||||
| @ -73,7 +75,8 @@ class Organization extends AbstractApiModel { | |||||||
|      * @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 &$client , ?object $caller, object $map): self { |     public static function fromJson(object &$client, ?object $caller, object $map): self | ||||||
|  |     { | ||||||
|         return ( |         return ( | ||||||
|             new static( |             new static( | ||||||
|                 $client, |                 $client, | ||||||
| @ -91,9 +94,10 @@ class Organization extends AbstractApiModel { | |||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 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 { |     public 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(), | ||||||
| @ -110,71 +114,85 @@ class Organization extends AbstractApiModel { | |||||||
|      * Gets the organization identifier. |      * Gets the organization identifier. | ||||||
|      * @return int The organization identifier. |      * @return int The organization identifier. | ||||||
|      */ |      */ | ||||||
|     function getId(): int { |     public 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; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -2,16 +2,18 @@ | |||||||
|  |  | ||||||
| namespace Gitea\Model; | namespace Gitea\Model; | ||||||
|  |  | ||||||
|  | use Gitea\Client; | ||||||
| use GuzzleHttp\Psr7\Uri; | use GuzzleHttp\Psr7\Uri; | ||||||
| use Psr\Http\Message\UriInterface; | use Psr\Http\Message\UriInterface; | ||||||
|  |  | ||||||
| use Gitea\Client; | use stdClass; | ||||||
|  | use InvalidArgumentException; | ||||||
|  |  | ||||||
| use Gitea\Model\Abstracts\AbstractApiModel; | use Gitea\Model\Abstracts\AbstractApiModel; | ||||||
|  |  | ||||||
| /** Represents a Gitea owner. */ | /** Represents a Gitea owner. */ | ||||||
| class Owner extends AbstractApiModel { | class Owner extends AbstractApiModel | ||||||
|  | { | ||||||
|     /** @var int The owner identifier. */ |     /** @var int The owner identifier. */ | ||||||
|     private $id; |     private $id; | ||||||
|  |  | ||||||
| @ -43,7 +45,8 @@ class Owner extends AbstractApiModel { | |||||||
|      * @param int $id The owner identifier. |      * @param int $id The owner identifier. | ||||||
|      * @param string $login The name of the Gitea account. |      * @param string $login The name of the Gitea account. | ||||||
|      */ |      */ | ||||||
|     public function __construct(Client &$client , ?object $caller, ...$args) { |     public function __construct(Client &$client, ?object $caller, ...$args) | ||||||
|  |     { | ||||||
|         parent::__construct($client, $caller, $args); |         parent::__construct($client, $caller, $args); | ||||||
|         if (count($args) >= 2) { |         if (count($args) >= 2) { | ||||||
|             $id = $args[0]; |             $id = $args[0]; | ||||||
| @ -71,7 +74,8 @@ class Owner extends AbstractApiModel { | |||||||
|      * @param object $map A JSON map representing a owner. |      * @param object $map A JSON map representing a owner. | ||||||
|      * @return static The instance corresponding to the specified JSON map. |      * @return static The instance corresponding to the specified JSON map. | ||||||
|      */ |      */ | ||||||
|     static function fromJson(object &$client , ?object $caller, object $map): self { |     public static function fromJson(object &$client, ?object $caller, object $map): self | ||||||
|  |     { | ||||||
|         return ( |         return ( | ||||||
|             new static( |             new static( | ||||||
|                 $client, |                 $client, | ||||||
| @ -90,9 +94,10 @@ class Owner extends AbstractApiModel { | |||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 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 { |     public function jsonSerialize(): stdClass | ||||||
|  |     { | ||||||
|         return (object) [ |         return (object) [ | ||||||
|             'id' => $this->getId(), |             'id' => $this->getId(), | ||||||
|             'login' => $this->getLogin(), |             'login' => $this->getLogin(), | ||||||
| @ -109,7 +114,8 @@ class Owner extends AbstractApiModel { | |||||||
|      * Gets the owner identifier. |      * Gets the owner identifier. | ||||||
|      * @return int The owner identifier. |      * @return int The owner identifier. | ||||||
|      */ |      */ | ||||||
|     function getId(): int { |     public function getId(): int | ||||||
|  |     { | ||||||
|         return $this->id; |         return $this->id; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -117,7 +123,8 @@ class Owner extends AbstractApiModel { | |||||||
|      * 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 { |     public function getLogin(): string | ||||||
|  |     { | ||||||
|         return $this->login; |         return $this->login; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -126,7 +133,8 @@ class Owner extends AbstractApiModel { | |||||||
|      * @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 { |     public function setLogin(string $value): self | ||||||
|  |     { | ||||||
|         $this->login = $value; |         $this->login = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -135,7 +143,8 @@ class Owner extends AbstractApiModel { | |||||||
|      * Gets the full name. |      * Gets the full name. | ||||||
|      * @return string The full name. |      * @return string The full name. | ||||||
|      */ |      */ | ||||||
|     function getFullName(): string { |     public function getFullName(): string | ||||||
|  |     { | ||||||
|         return $this->fullName; |         return $this->fullName; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -144,7 +153,8 @@ class Owner extends AbstractApiModel { | |||||||
|      * @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 { |     public function setFullName(string $value): self | ||||||
|  |     { | ||||||
|         $this->fullName = $value; |         $this->fullName = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -153,7 +163,8 @@ class Owner extends AbstractApiModel { | |||||||
|      * Gets the mail address. |      * Gets the mail address. | ||||||
|      * @return string The mail address. |      * @return string The mail address. | ||||||
|      */ |      */ | ||||||
|     function getEmail(): string { |     public function getEmail(): string | ||||||
|  |     { | ||||||
|         return $this->email; |         return $this->email; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -162,7 +173,8 @@ class Owner extends AbstractApiModel { | |||||||
|      * @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 { |     public function setEmail(string $value): self | ||||||
|  |     { | ||||||
|         $this->email = $value; |         $this->email = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -171,7 +183,8 @@ class Owner extends AbstractApiModel { | |||||||
|      * 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 { |     public function getAvatarUrl(): ?UriInterface | ||||||
|  |     { | ||||||
|         return $this->avatarUrl; |         return $this->avatarUrl; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -180,7 +193,8 @@ class Owner extends AbstractApiModel { | |||||||
|      * @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 { |     public function setAvatarUrl(?UriInterface $value): self | ||||||
|  |     { | ||||||
|         $this->avatarUrl = $value; |         $this->avatarUrl = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -189,7 +203,8 @@ class Owner extends AbstractApiModel { | |||||||
|      * Gets the owner locale. |      * Gets the owner locale. | ||||||
|      * @return string The owner locale. |      * @return string The owner locale. | ||||||
|      */ |      */ | ||||||
|     function getLanguage(): string { |     public function getLanguage(): string | ||||||
|  |     { | ||||||
|         return $this->language; |         return $this->language; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -198,27 +213,31 @@ class Owner extends AbstractApiModel { | |||||||
|      * @param string $value The new owner locale. |      * @param string $value The new owner locale. | ||||||
|      * @return $this This instance. |      * @return $this This instance. | ||||||
|      */ |      */ | ||||||
|     function setLanguage(string $value): self { |     public function setLanguage(string $value): self | ||||||
|  |     { | ||||||
|         $this->language = $value; |         $this->language = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getIsAdmin(): bool { |     public function getIsAdmin(): bool | ||||||
|  |     { | ||||||
|         return $this->isAdmin; |         return $this->isAdmin; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function setIsAdmin($boolean): self { |     public function setIsAdmin($boolean): self | ||||||
|  |     { | ||||||
|         $this->isAdmin = $boolean; |         $this->isAdmin = $boolean; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getUsername(): string { |     public function getUsername(): string | ||||||
|  |     { | ||||||
|         return $this->username; |         return $this->username; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function setUsername($string): self { |     public function setUsername($string): self | ||||||
|  |     { | ||||||
|         $this->username = $string; |         $this->username = $string; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -9,13 +9,15 @@ use Gitea\Client; | |||||||
| use Gitea\Model\PayloadUser; | use Gitea\Model\PayloadUser; | ||||||
| use Gitea\Model\PayloadCommitVerification; | use Gitea\Model\PayloadCommitVerification; | ||||||
|  |  | ||||||
| use \InvalidArgumentException; | use stdClass; | ||||||
|  | use DateTime; | ||||||
|  | use InvalidArgumentException; | ||||||
|  |  | ||||||
| use Gitea\Model\Abstracts\AbstractApiModel; | use Gitea\Model\Abstracts\AbstractApiModel; | ||||||
|  |  | ||||||
| /** Represents a commit. */ | /** Represents a commit. */ | ||||||
| class PayloadCommit extends AbstractApiModel { | class PayloadCommit extends AbstractApiModel | ||||||
|  | { | ||||||
|     /** @var PayloadUser|null The person who authored the commit. */ |     /** @var PayloadUser|null The person who authored the commit. */ | ||||||
|     private $author; |     private $author; | ||||||
|  |  | ||||||
| @ -28,7 +30,7 @@ class PayloadCommit extends AbstractApiModel { | |||||||
|     /** @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. */ | ||||||
| @ -44,7 +46,8 @@ class PayloadCommit extends AbstractApiModel { | |||||||
|      * @param string $id The commit hash. |      * @param string $id The commit hash. | ||||||
|      * @param string $message The commit message. |      * @param string $message The commit message. | ||||||
|      */ |      */ | ||||||
|     public function __construct(Client &$client , ?object $caller, ...$args) { |     public function __construct(Client &$client, ?object $caller, ...$args) | ||||||
|  |     { | ||||||
|         parent::__construct($client, $caller, $args); |         parent::__construct($client, $caller, $args); | ||||||
|         if (count($args) >= 2) { |         if (count($args) >= 2) { | ||||||
|             $id = $args[0]; |             $id = $args[0]; | ||||||
| @ -72,7 +75,8 @@ class PayloadCommit extends AbstractApiModel { | |||||||
|      * @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 &$client , ?object $caller, object $map): self { |     public static function fromJson(object &$client, ?object $caller, object $map): self | ||||||
|  |     { | ||||||
|         return ( |         return ( | ||||||
|             new static( |             new static( | ||||||
|                 $client, |                 $client, | ||||||
| @ -83,7 +87,7 @@ class PayloadCommit extends AbstractApiModel { | |||||||
|         ) |         ) | ||||||
|         ->setAuthor(isset($map->author) && is_object($map->author) ? PayloadUser::fromJson($client, null, $map->author) : null) |         ->setAuthor(isset($map->author) && is_object($map->author) ? PayloadUser::fromJson($client, null, $map->author) : null) | ||||||
|         ->setCommitter(isset($map->committer) && is_object($map->committer) ? PayloadUser::fromJson($client, null, $map->committer) : null) |         ->setCommitter(isset($map->committer) && is_object($map->committer) ? PayloadUser::fromJson($client, null, $map->committer) : null) | ||||||
|         ->setTimestamp(isset($map->timestamp) && is_string($map->timestamp) ? new \DateTime($map->timestamp) : null) |         ->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($client, null, $map->verification) : null); |         ->setVerification(isset($map->verification) && is_object($map->verification) ? PayloadCommitVerification::fromJson($client, null, $map->verification) : null); | ||||||
|     } |     } | ||||||
| @ -92,7 +96,8 @@ class PayloadCommit extends AbstractApiModel { | |||||||
|      * 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 { |     public function getAuthor(): ?PayloadUser | ||||||
|  |     { | ||||||
|         return $this->author; |         return $this->author; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -100,7 +105,8 @@ class PayloadCommit extends AbstractApiModel { | |||||||
|      * 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 { |     public function getCommitter(): ?PayloadUser | ||||||
|  |     { | ||||||
|         return $this->committer; |         return $this->committer; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -108,7 +114,8 @@ class PayloadCommit extends AbstractApiModel { | |||||||
|      * Gets the commit hash. |      * Gets the commit hash. | ||||||
|      * @return string The commit hash. |      * @return string The commit hash. | ||||||
|      */ |      */ | ||||||
|     function getId(): string { |     public function getId(): string | ||||||
|  |     { | ||||||
|         return $this->id; |         return $this->id; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -116,15 +123,17 @@ class PayloadCommit extends AbstractApiModel { | |||||||
|      * Gets the commit message. |      * Gets the commit message. | ||||||
|      * @return string The commit message. |      * @return string The commit message. | ||||||
|      */ |      */ | ||||||
|     function getMessage(): string { |     public 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 { |     public function getTimestamp(): ?DateTime | ||||||
|  |     { | ||||||
|         return $this->timestamp; |         return $this->timestamp; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -132,7 +141,8 @@ class PayloadCommit extends AbstractApiModel { | |||||||
|      * 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 { |     public function getUrl(): ?UriInterface | ||||||
|  |     { | ||||||
|         return $this->url; |         return $this->url; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -140,15 +150,17 @@ class PayloadCommit extends AbstractApiModel { | |||||||
|      * 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 { |     public 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 { |     public 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, | ||||||
| @ -165,7 +177,8 @@ class PayloadCommit extends AbstractApiModel { | |||||||
|      * @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 { |     public function setAuthor(?PayloadUser $value): self | ||||||
|  |     { | ||||||
|         $this->author = $value; |         $this->author = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -175,7 +188,8 @@ class PayloadCommit extends AbstractApiModel { | |||||||
|      * @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 { |     public function setCommitter(?PayloadUser $value): self | ||||||
|  |     { | ||||||
|         $this->committer = $value; |         $this->committer = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -185,17 +199,19 @@ class PayloadCommit extends AbstractApiModel { | |||||||
|      * @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 { |     public 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 { |     public function setTimestamp(?DateTime $value): self | ||||||
|  |     { | ||||||
|         $this->timestamp = $value; |         $this->timestamp = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -205,7 +221,8 @@ class PayloadCommit extends AbstractApiModel { | |||||||
|      * @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 { |     public function setUrl(?UriInterface $value): self | ||||||
|  |     { | ||||||
|         $this->url = $value; |         $this->url = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -215,7 +232,8 @@ class PayloadCommit extends AbstractApiModel { | |||||||
|      * @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 { |     public function setVerification(?PayloadCommitVerification $value): self | ||||||
|  |     { | ||||||
|         $this->verification = $value; |         $this->verification = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -7,13 +7,14 @@ use Psr\Http\Message\UriInterface; | |||||||
|  |  | ||||||
| use Gitea\Client; | use Gitea\Client; | ||||||
|  |  | ||||||
| use \InvalidArgumentException; | use stdClass; | ||||||
|  | use InvalidArgumentException; | ||||||
|  |  | ||||||
| use Gitea\Model\Abstracts\AbstractApiModel; | use Gitea\Model\Abstracts\AbstractApiModel; | ||||||
|  |  | ||||||
| /** Represents the GPG verification of a commit. */ | /** Represents the GPG verification of a commit. */ | ||||||
| class PayloadCommitVerification extends AbstractApiModel { | class PayloadCommitVerification extends AbstractApiModel | ||||||
|  | { | ||||||
|     /** @var bool Value indicating whether the verification has succeeded. */ |     /** @var bool Value indicating whether the verification has succeeded. */ | ||||||
|     private $isVerified; |     private $isVerified; | ||||||
|  |  | ||||||
| @ -32,7 +33,8 @@ class PayloadCommitVerification extends AbstractApiModel { | |||||||
|      * @param object|null $caller The object that called this method |      * @param object|null $caller The object that called this method | ||||||
|      * @param bool $isVerified Value indicating whether the verification has succeeded. |      * @param bool $isVerified Value indicating whether the verification has succeeded. | ||||||
|      */ |      */ | ||||||
|     public function __construct(Client &$client , ?object $caller, ...$args) { |     public function __construct(Client &$client, ?object $caller, ...$args) | ||||||
|  |     { | ||||||
|         parent::__construct($client, $caller, $args); |         parent::__construct($client, $caller, $args); | ||||||
|         if (count($args) >= 1) { |         if (count($args) >= 1) { | ||||||
|             $isVerified = $args[0]; |             $isVerified = $args[0]; | ||||||
| @ -54,7 +56,8 @@ class PayloadCommitVerification extends AbstractApiModel { | |||||||
|      * @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 &$client , ?object $caller, object $map): self { |     public static function fromJson(object &$client, ?object $caller, object $map): self | ||||||
|  |     { | ||||||
|         return ( |         return ( | ||||||
|             new static( |             new static( | ||||||
|                 $client, |                 $client, | ||||||
| @ -71,7 +74,8 @@ class PayloadCommitVerification extends AbstractApiModel { | |||||||
|      * 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 { |     public function getPayload(): string | ||||||
|  |     { | ||||||
|         return $this->payload; |         return $this->payload; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -79,7 +83,8 @@ class PayloadCommitVerification extends AbstractApiModel { | |||||||
|      * 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 { |     public function getReason(): string | ||||||
|  |     { | ||||||
|         return $this->reason; |         return $this->reason; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -87,7 +92,8 @@ class PayloadCommitVerification extends AbstractApiModel { | |||||||
|      * 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 { |     public function getSignature(): string | ||||||
|  |     { | ||||||
|         return $this->signature; |         return $this->signature; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -95,15 +101,17 @@ class PayloadCommitVerification extends AbstractApiModel { | |||||||
|      * 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 { |     public 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 { |     public function jsonSerialize(): stdClass | ||||||
|  |     { | ||||||
|         return (object) [ |         return (object) [ | ||||||
|             'payload' => $this->getPayload(), |             'payload' => $this->getPayload(), | ||||||
|             'reason' => $this->getReason(), |             'reason' => $this->getReason(), | ||||||
| @ -117,7 +125,8 @@ class PayloadCommitVerification extends AbstractApiModel { | |||||||
|      * @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 { |     public function setPayload(string $value): self | ||||||
|  |     { | ||||||
|         $this->payload = $value; |         $this->payload = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -127,7 +136,8 @@ class PayloadCommitVerification extends AbstractApiModel { | |||||||
|      * @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 { |     public function setReason(string $value): self | ||||||
|  |     { | ||||||
|         $this->reason = $value; |         $this->reason = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -137,7 +147,8 @@ class PayloadCommitVerification extends AbstractApiModel { | |||||||
|      * @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 { |     public function setSignature(string $value): self | ||||||
|  |     { | ||||||
|         $this->signature = $value; |         $this->signature = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -147,7 +158,8 @@ class PayloadCommitVerification extends AbstractApiModel { | |||||||
|      * @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 { |     public function setVerified(bool $value): self | ||||||
|  |     { | ||||||
|         $this->isVerified = $value; |         $this->isVerified = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -7,14 +7,14 @@ use Psr\Http\Message\UriInterface; | |||||||
|  |  | ||||||
| use Gitea\Client; | use Gitea\Client; | ||||||
|  |  | ||||||
| use \stdClass; | use stdClass; | ||||||
| use \InvalidArgumentException; | use InvalidArgumentException; | ||||||
|  |  | ||||||
| use Gitea\Model\Abstracts\AbstractApiModel; | use Gitea\Model\Abstracts\AbstractApiModel; | ||||||
|  |  | ||||||
| /** Represents the author or committer of a commit. */ | /** Represents the author or committer of a commit. */ | ||||||
| class PayloadUser extends AbstractApiModel { | class PayloadUser extends AbstractApiModel | ||||||
|  | { | ||||||
|     /** @var string The mail address. */ |     /** @var string The mail address. */ | ||||||
|     private $email = ''; |     private $email = ''; | ||||||
|  |  | ||||||
| @ -30,7 +30,8 @@ class PayloadUser extends AbstractApiModel { | |||||||
|      * @param object|null $caller The object that called this method |      * @param object|null $caller The object that called this method | ||||||
|      * @param string $username The name of the Gitea account. |      * @param string $username The name of the Gitea account. | ||||||
|      */ |      */ | ||||||
|     public function __construct(Client &$client , ?object $caller, ...$args) { |     public function __construct(Client &$client, ?object $caller, ...$args) | ||||||
|  |     { | ||||||
|         parent::__construct($client, $caller, $args); |         parent::__construct($client, $caller, $args); | ||||||
|         if (count($args) >= 1) { |         if (count($args) >= 1) { | ||||||
|             $username = $args[0]; |             $username = $args[0]; | ||||||
| @ -52,7 +53,8 @@ class PayloadUser extends AbstractApiModel { | |||||||
|      * @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 &$client , ?object $caller, object $map): self { |     public static function fromJson(object &$client, ?object $caller, object $map): self | ||||||
|  |     { | ||||||
|         return ( |         return ( | ||||||
|             new static( |             new static( | ||||||
|                 $client, |                 $client, | ||||||
| @ -68,7 +70,8 @@ class PayloadUser extends AbstractApiModel { | |||||||
|      * Gets the mail address. |      * Gets the mail address. | ||||||
|      * @return string The mail address. |      * @return string The mail address. | ||||||
|      */ |      */ | ||||||
|     function getEmail(): string { |     public function getEmail(): string | ||||||
|  |     { | ||||||
|         return $this->email; |         return $this->email; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -76,7 +79,8 @@ class PayloadUser extends AbstractApiModel { | |||||||
|      * Gets the full name. |      * Gets the full name. | ||||||
|      * @return string The full name. |      * @return string The full name. | ||||||
|      */ |      */ | ||||||
|     function getName(): string { |     public function getName(): string | ||||||
|  |     { | ||||||
|         return $this->name; |         return $this->name; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -84,7 +88,8 @@ class PayloadUser extends AbstractApiModel { | |||||||
|      * 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 { |     public function getUsername(): string | ||||||
|  |     { | ||||||
|         return $this->username; |         return $this->username; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -92,7 +97,8 @@ class PayloadUser extends AbstractApiModel { | |||||||
|      * 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 { |     public function jsonSerialize(): stdClass | ||||||
|  |     { | ||||||
|         return (object) [ |         return (object) [ | ||||||
|             'email' => $this->getEmail(), |             'email' => $this->getEmail(), | ||||||
|             'name' => $this->getName(), |             'name' => $this->getName(), | ||||||
| @ -105,7 +111,8 @@ class PayloadUser extends AbstractApiModel { | |||||||
|      * @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 { |     public function setEmail(string $value): self | ||||||
|  |     { | ||||||
|         $this->email = $value; |         $this->email = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -115,7 +122,8 @@ class PayloadUser extends AbstractApiModel { | |||||||
|      * @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 { |     public function setName(string $value): self | ||||||
|  |     { | ||||||
|         $this->name = $value; |         $this->name = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -7,13 +7,14 @@ use Psr\Http\Message\UriInterface; | |||||||
|  |  | ||||||
| use Gitea\Client; | use Gitea\Client; | ||||||
|  |  | ||||||
| use \InvalidArgumentException; | use stdClass; | ||||||
|  | use InvalidArgumentException; | ||||||
|  |  | ||||||
| use Gitea\Model\Abstracts\AbstractApiModel; | use Gitea\Model\Abstracts\AbstractApiModel; | ||||||
|  |  | ||||||
| /** Represents a set of permissions. */ | /** Represents a set of permissions. */ | ||||||
| class Permission extends AbstractApiModel { | class Permission extends AbstractApiModel | ||||||
|  | { | ||||||
|     /** @var bool Value indicating whether administrator access is allowed. */ |     /** @var bool Value indicating whether administrator access is allowed. */ | ||||||
|     private $admin; |     private $admin; | ||||||
|  |  | ||||||
| @ -31,7 +32,8 @@ class Permission extends AbstractApiModel { | |||||||
|      * @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. | ||||||
|      */ |      */ | ||||||
|     public function __construct(Client &$client , ?object $caller, ...$args) { |     public function __construct(Client &$client, ?object $caller, ...$args) | ||||||
|  |     { | ||||||
|         parent::__construct($client, $caller, $args); |         parent::__construct($client, $caller, $args); | ||||||
|         if (count($args) >= 2) { |         if (count($args) >= 2) { | ||||||
|             $admin = $args[0]; |             $admin = $args[0]; | ||||||
| @ -63,7 +65,8 @@ class Permission extends AbstractApiModel { | |||||||
|      * @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 &$client , ?object $caller, object $map): self { |     public static function fromJson(object &$client, ?object $caller, object $map): self | ||||||
|  |     { | ||||||
|         return new static( |         return new static( | ||||||
|             $client, |             $client, | ||||||
|             $caller, |             $caller, | ||||||
| @ -77,7 +80,8 @@ class Permission extends AbstractApiModel { | |||||||
|      * 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 { |     public function getAdmin(): bool | ||||||
|  |     { | ||||||
|         return $this->admin; |         return $this->admin; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -85,7 +89,8 @@ class Permission extends AbstractApiModel { | |||||||
|      * 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 { |     public function getPull(): bool | ||||||
|  |     { | ||||||
|         return $this->pull; |         return $this->pull; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -93,15 +98,17 @@ class Permission extends AbstractApiModel { | |||||||
|      * 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 { |     public 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 { |     public function jsonSerialize(): stdClass | ||||||
|  |     { | ||||||
|         return (object) [ |         return (object) [ | ||||||
|             'admin' => $this->getAdmin(), |             'admin' => $this->getAdmin(), | ||||||
|             'pull' => $this->getPull(), |             'pull' => $this->getPull(), | ||||||
| @ -114,7 +121,8 @@ class Permission extends AbstractApiModel { | |||||||
|      * @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 { |     public function setAdmin(bool $value): self | ||||||
|  |     { | ||||||
|         $this->admin = $value; |         $this->admin = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -124,7 +132,8 @@ class Permission extends AbstractApiModel { | |||||||
|      * @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 { |     public function setPull(bool $value): self | ||||||
|  |     { | ||||||
|         $this->pull = $value; |         $this->pull = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -134,7 +143,8 @@ class Permission extends AbstractApiModel { | |||||||
|      * @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 { |     public function setPush(bool $value): self | ||||||
|  |     { | ||||||
|         $this->push = $value; |         $this->push = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| <?php declare(strict_types=1); | <?php | ||||||
|  | declare(strict_types=1); | ||||||
|  |  | ||||||
| namespace Gitea\Model; | namespace Gitea\Model; | ||||||
|  |  | ||||||
| @ -12,17 +13,19 @@ use Gitea\Api\Repositories; | |||||||
| use Gitea\Api\Branches; | use Gitea\Api\Branches; | ||||||
| use Gitea\Api\Tags; | use Gitea\Api\Tags; | ||||||
|  |  | ||||||
| use \InvalidArgumentException; | use stdClass; | ||||||
|  | use DateTime; | ||||||
|  | use InvalidArgumentException; | ||||||
|  |  | ||||||
| use Gitea\Model\Abstracts\AbstractApiModel; | use Gitea\Model\Abstracts\AbstractApiModel; | ||||||
|  |  | ||||||
| /** Represents a repository. */ | /** Represents a repository. */ | ||||||
| class Repository extends AbstractApiModel { | class Repository extends AbstractApiModel | ||||||
|  | { | ||||||
|     /** @var UriInterface|null The HTTP-based URL for cloning this repository. */ |     /** @var UriInterface|null The HTTP-based URL for cloning this repository. */ | ||||||
|     private $cloneUrl; |     private $cloneUrl; | ||||||
|  |  | ||||||
|     /** @var \DateTime|null The date the repository was created. */ |     /** @var DateTime|null The date the repository was created. */ | ||||||
|     private $createdAt; |     private $createdAt; | ||||||
|  |  | ||||||
|     /** @var string The name of the default branch. */ |     /** @var string The name of the default branch. */ | ||||||
| @ -79,7 +82,7 @@ class Repository extends AbstractApiModel { | |||||||
|     /** @var int The number of stars of this repository. */ |     /** @var int The number of stars of this repository. */ | ||||||
|     private $starsCount = 0; |     private $starsCount = 0; | ||||||
|  |  | ||||||
|     /** @var \DateTime|null The date the repository was updated. */ |     /** @var DateTime|null The date the repository was updated. */ | ||||||
|     private $updatedAt; |     private $updatedAt; | ||||||
|  |  | ||||||
|     /** @var int The number of watchers of this repository. */ |     /** @var int The number of watchers of this repository. */ | ||||||
| @ -95,24 +98,34 @@ class Repository extends AbstractApiModel { | |||||||
|      * @param int $id The repository identifier. |      * @param int $id The repository identifier. | ||||||
|      * @param string $fullName The full name of the repository. |      * @param string $fullName The full name of the repository. | ||||||
|      */ |      */ | ||||||
|     public function __construct(Client &$client , ?object $caller, ...$args) { |     public function __construct(Client &$client, ?object $caller, ...$args) | ||||||
|  |     { | ||||||
|         parent::__construct($client, $caller, $args); |         parent::__construct($client, $caller, $args); | ||||||
|         if (count($args) >= 2) { |         if (count($args) >= 2) { | ||||||
|             $id = $args[0]; |             $id = $args[0]; | ||||||
|             $fullName = $args[1]; |             $fullName = $args[1]; | ||||||
|             if (!is_numeric($id)) { |             if (!is_numeric($id)) { | ||||||
|                 $argumentType = gettype($id); |                 $argumentType = gettype($id); | ||||||
|                 throw new InvalidArgumentException("The \"construct()\" function requires the 3rd parameter to be of the integer type, but a \"$argumentType\" was passed in"); |                 throw new InvalidArgumentException( | ||||||
|  |                     "The \"construct()\" function requires the 3rd parameter to be of" | ||||||
|  |                     ." the integer type, but a \"$argumentType\" was passed in" | ||||||
|  |                 ); | ||||||
|             } |             } | ||||||
|             if (!is_string($fullName)) { |             if (!is_string($fullName)) { | ||||||
|                 $argumentType = gettype($fullName); |                 $argumentType = gettype($fullName); | ||||||
|                 throw new InvalidArgumentException("The \"construct()\" function requires the 4th parameter to be of the string type, but a \"$argumentType\" was passed in"); |                 throw new InvalidArgumentException( | ||||||
|  |                     "The \"construct()\" function requires the 4th parameter to be of" | ||||||
|  |                     ." the string type, but a \"$argumentType\" was passed in" | ||||||
|  |                 ); | ||||||
|             } |             } | ||||||
|             $this->id = $id; |             $this->id = $id; | ||||||
|             $this->setFullName($fullName); |             $this->setFullName($fullName); | ||||||
|         } else { |         } else { | ||||||
|             $numArgs = func_num_args(); |             $numArgs = func_num_args(); | ||||||
|             throw new InvalidArgumentException("The \"construct()\" function requires 4 parameters but only $numArgs were passed in"); |             throw new InvalidArgumentException( | ||||||
|  |                 "The \"construct()\" function requires 4 parameters but only $numArgs" | ||||||
|  |                 ." were passed in" | ||||||
|  |             ); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -123,7 +136,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * @param object $map A JSON map representing a repository. |      * @param object $map A JSON map representing a repository. | ||||||
|      * @return static The instance corresponding to the specified JSON map. |      * @return static The instance corresponding to the specified JSON map. | ||||||
|      */ |      */ | ||||||
|     static function fromJson(object &$client , ?object $caller, object $map): self { |     public static function fromJson(object &$client, ?object $caller, object $map): self | ||||||
|  |     { | ||||||
|         return ( |         return ( | ||||||
|             new static( |             new static( | ||||||
|                 $client, |                 $client, | ||||||
| @ -133,7 +147,7 @@ class Repository extends AbstractApiModel { | |||||||
|             ) |             ) | ||||||
|         ) |         ) | ||||||
|         ->setCloneUrl(isset($map->clone_url) && is_string($map->clone_url) ? new Uri($map->clone_url) : null) |         ->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) |         ->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 : '') |         ->setDefaultBranch(isset($map->default_branch) && is_string($map->default_branch) ? $map->default_branch : '') | ||||||
|         ->setDescription(isset($map->description) && is_string($map->description) ? $map->description : '') |         ->setDescription(isset($map->description) && is_string($map->description) ? $map->description : '') | ||||||
|         ->setEmpty(isset($map->empty) && is_bool($map->empty) ? $map->empty : true) |         ->setEmpty(isset($map->empty) && is_bool($map->empty) ? $map->empty : true) | ||||||
| @ -142,15 +156,27 @@ class Repository extends AbstractApiModel { | |||||||
|         ->setHtmlUrl(isset($map->html_url) && is_string($map->html_url) ? new Uri($map->html_url) : null) |         ->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) |         ->setMirror(isset($map->mirror) && is_bool($map->mirror) ? $map->mirror : false) | ||||||
|         ->setName(isset($map->name) && is_string($map->name) ? $map->name : '') |         ->setName(isset($map->name) && is_string($map->name) ? $map->name : '') | ||||||
|         ->setOpenIssuesCount(isset($map->open_issues_count) && is_numeric($map->open_issues_count) ? $map->open_issues_count : 0) |         ->setOpenIssuesCount( | ||||||
|  |             isset($map->open_issues_count) | ||||||
|  |             && is_numeric($map->open_issues_count) | ||||||
|  |             ? $map->open_issues_count : 0 | ||||||
|  |         ) | ||||||
|         ->setOwner(isset($map->owner) && is_object($map->owner) ? Owner::fromJson($client, null, $map->owner) : null) |         ->setOwner(isset($map->owner) && is_object($map->owner) ? Owner::fromJson($client, null, $map->owner) : null) | ||||||
|         ->setParent(isset($map->parent) && is_object($map->parent) ? Repository::fromJson($client, null, $map->parent) : null) |         ->setParent( | ||||||
|         ->setPermissions(isset($map->permissions) && is_object($map->permissions) ? Permission::fromJson($client, null, $map->permissions) : null) |             isset($map->parent) | ||||||
|  |             && is_object($map->parent) | ||||||
|  |             ? Repository::fromJson($client, null, $map->parent) : null | ||||||
|  |         ) | ||||||
|  |         ->setPermissions( | ||||||
|  |             isset($map->permissions) | ||||||
|  |             && is_object($map->permissions) | ||||||
|  |             ? Permission::fromJson($client, null, $map->permissions) : null | ||||||
|  |         ) | ||||||
|         ->setPrivate(isset($map->private) && is_bool($map->private) ? $map->private : false) |         ->setPrivate(isset($map->private) && is_bool($map->private) ? $map->private : false) | ||||||
|         ->setSize(isset($map->size) && is_numeric($map->size) ? $map->size : 0) |         ->setSize(isset($map->size) && is_numeric($map->size) ? $map->size : 0) | ||||||
|         ->setSshUrl(isset($map->ssh_url) && is_string($map->ssh_url) ? new Uri($map->ssh_url) : null) |         ->setSshUrl(isset($map->ssh_url) && is_string($map->ssh_url) ? new Uri($map->ssh_url) : null) | ||||||
|         ->setStarsCount(isset($map->stars_count) && is_numeric($map->stars_count) ? $map->stars_count : 0) |         ->setStarsCount(isset($map->stars_count) && is_numeric($map->stars_count) ? $map->stars_count : 0) | ||||||
|         ->setUpdatedAt(isset($map->updated_at) && is_string($map->updated_at) ? new \DateTime($map->updated_at) : null) |         ->setUpdatedAt(isset($map->updated_at) && is_string($map->updated_at) ? new DateTime($map->updated_at) : null) | ||||||
|         ->setWatchersCount(isset($map->watchers_count) && is_numeric($map->watchers_count) ? $map->watchers_count : 0) |         ->setWatchersCount(isset($map->watchers_count) && is_numeric($map->watchers_count) ? $map->watchers_count : 0) | ||||||
|         ->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); | ||||||
|     } |     } | ||||||
| @ -159,15 +185,17 @@ class Repository extends AbstractApiModel { | |||||||
|      * Gets the HTTP-based URL for cloning this repository. |      * Gets the HTTP-based URL for cloning this repository. | ||||||
|      * @return UriInterface|null The HTTP-based URL for cloning this repository. |      * @return UriInterface|null The HTTP-based URL for cloning this repository. | ||||||
|      */ |      */ | ||||||
|     function getCloneUrl(): ?UriInterface { |     public function getCloneUrl(): ?UriInterface | ||||||
|  |     { | ||||||
|         return $this->cloneUrl; |         return $this->cloneUrl; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Gets the date the repository was created. |      * Gets the date the repository was created. | ||||||
|      * @return \DateTime|null The date the repository was created. |      * @return DateTime|null The date the repository was created. | ||||||
|      */ |      */ | ||||||
|     function getCreatedAt(): ?\DateTime { |     public function getCreatedAt(): ?DateTime | ||||||
|  |     { | ||||||
|         return $this->createdAt; |         return $this->createdAt; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -175,7 +203,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * Gets the name of the default branch. |      * Gets the name of the default branch. | ||||||
|      * @return string The name of the default branch. |      * @return string The name of the default branch. | ||||||
|      */ |      */ | ||||||
|     function getDefaultBranch(): string { |     public function getDefaultBranch(): string | ||||||
|  |     { | ||||||
|         return $this->defaultBranch; |         return $this->defaultBranch; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -183,7 +212,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * Gets the repository description. |      * Gets the repository description. | ||||||
|      * @return string The repository description. |      * @return string The repository description. | ||||||
|      */ |      */ | ||||||
|     function getDescription(): string { |     public function getDescription(): string | ||||||
|  |     { | ||||||
|         return $this->description; |         return $this->description; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -191,7 +221,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * Gets the number of forks of this repository. |      * Gets the number of forks of this repository. | ||||||
|      * @return int The number of forks of this repository. |      * @return int The number of forks of this repository. | ||||||
|      */ |      */ | ||||||
|     function getForksCount(): int { |     public function getForksCount(): int | ||||||
|  |     { | ||||||
|         return $this->forksCount; |         return $this->forksCount; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -199,7 +230,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * Gets the full name. |      * Gets the full name. | ||||||
|      * @return string The full name. |      * @return string The full name. | ||||||
|      */ |      */ | ||||||
|     function getFullName(): string { |     public function getFullName(): string | ||||||
|  |     { | ||||||
|         return $this->fullName; |         return $this->fullName; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -207,7 +239,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * Gets the Gitea URL of this repository. |      * Gets the Gitea URL of this repository. | ||||||
|      * @return UriInterface|null The Gitea URL of this repository. |      * @return UriInterface|null The Gitea URL of this repository. | ||||||
|      */ |      */ | ||||||
|     function getHtmlUrl(): ?UriInterface { |     public function getHtmlUrl(): ?UriInterface | ||||||
|  |     { | ||||||
|         return $this->htmlUrl; |         return $this->htmlUrl; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -215,7 +248,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * Gets the repository identifier. |      * Gets the repository identifier. | ||||||
|      * @return int The repository identifier. |      * @return int The repository identifier. | ||||||
|      */ |      */ | ||||||
|     function getId(): int { |     public function getId(): int | ||||||
|  |     { | ||||||
|         return $this->id; |         return $this->id; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -223,8 +257,11 @@ class Repository extends AbstractApiModel { | |||||||
|      * Gets the repository name. |      * Gets the repository name. | ||||||
|      * @return string The repository name. |      * @return string The repository name. | ||||||
|      */ |      */ | ||||||
|     function getName(): string { |     public function getName(): string | ||||||
|         if (mb_strlen($this->name)) return $this->name; |     { | ||||||
|  |         if (mb_strlen($this->name)) { | ||||||
|  |             return $this->name; | ||||||
|  |         } | ||||||
|         return mb_strlen($fullName = $this->getFullName()) ? explode('/', $fullName)[1] : ''; |         return mb_strlen($fullName = $this->getFullName()) ? explode('/', $fullName)[1] : ''; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -232,7 +269,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * Gets the number of open issues of this repository. |      * Gets the number of open issues of this repository. | ||||||
|      * @return int The number of open issues of this repository. |      * @return int The number of open issues of this repository. | ||||||
|      */ |      */ | ||||||
|     function getOpenIssuesCount(): int { |     public function getOpenIssuesCount(): int | ||||||
|  |     { | ||||||
|         return $this->openIssuesCount; |         return $this->openIssuesCount; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -240,7 +278,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * Gets the repository owner. |      * Gets the repository owner. | ||||||
|      * @return User|null The repository owner. |      * @return User|null The repository owner. | ||||||
|      */ |      */ | ||||||
|     function getOwner(): ?Owner { |     public function getOwner(): ?Owner | ||||||
|  |     { | ||||||
|         return $this->owner; |         return $this->owner; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -248,7 +287,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * Gets the parent repository, if this repository is a fork or a mirror. |      * 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. |      * @return Repository|null The parent repository, if this repository is a fork or a mirror. | ||||||
|      */ |      */ | ||||||
|     function getParent(): ?Repository { |     public function getParent(): ?Repository | ||||||
|  |     { | ||||||
|         return $this->parent; |         return $this->parent; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -256,7 +296,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * Gets the repository permissions. |      * Gets the repository permissions. | ||||||
|      * @return Permission|null The repository permissions. |      * @return Permission|null The repository permissions. | ||||||
|      */ |      */ | ||||||
|     function getPermissions(): ?Permission { |     public function getPermissions(): ?Permission | ||||||
|  |     { | ||||||
|         return $this->permissions; |         return $this->permissions; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -264,7 +305,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * Gets the repository size, in kilobytes. |      * Gets the repository size, in kilobytes. | ||||||
|      * @return int The repository size, in kilobytes. |      * @return int The repository size, in kilobytes. | ||||||
|      */ |      */ | ||||||
|     function getSize(): int { |     public function getSize(): int | ||||||
|  |     { | ||||||
|         return $this->size; |         return $this->size; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -272,7 +314,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * Gets the SSH-based URL for cloning this repository. |      * Gets the SSH-based URL for cloning this repository. | ||||||
|      * @return UriInterface|null The SSH-based URL for cloning this repository. |      * @return UriInterface|null The SSH-based URL for cloning this repository. | ||||||
|      */ |      */ | ||||||
|     function getSshUrl(): ?UriInterface { |     public function getSshUrl(): ?UriInterface | ||||||
|  |     { | ||||||
|         return $this->sshUrl; |         return $this->sshUrl; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -280,15 +323,17 @@ class Repository extends AbstractApiModel { | |||||||
|      * Gets the number of stars of this repository. |      * Gets the number of stars of this repository. | ||||||
|      * @return int The number of stars of this repository. |      * @return int The number of stars of this repository. | ||||||
|      */ |      */ | ||||||
|     function getStarsCount(): int { |     public function getStarsCount(): int | ||||||
|  |     { | ||||||
|         return $this->starsCount; |         return $this->starsCount; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Gets the date the repository was updated. |      * Gets the date the repository was updated. | ||||||
|      * @return \DateTime|null The date the repository was updated. |      * @return DateTime|null The date the repository was updated. | ||||||
|      */ |      */ | ||||||
|     function getUpdatedAt(): ?\DateTime { |     public function getUpdatedAt(): ?DateTime | ||||||
|  |     { | ||||||
|         return $this->updatedAt; |         return $this->updatedAt; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -296,7 +341,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * Gets the number of watchers of this repository. |      * Gets the number of watchers of this repository. | ||||||
|      * @return int The number of watchers of this repository. |      * @return int The number of watchers of this repository. | ||||||
|      */ |      */ | ||||||
|     function getWatchersCount(): int { |     public function getWatchersCount(): int | ||||||
|  |     { | ||||||
|         return $this->watchersCount; |         return $this->watchersCount; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -304,7 +350,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * Gets the URL of the repository website. |      * Gets the URL of the repository website. | ||||||
|      * @return UriInterface|null The URL of the repository website. |      * @return UriInterface|null The URL of the repository website. | ||||||
|      */ |      */ | ||||||
|     function getWebsite(): ?UriInterface { |     public function getWebsite(): ?UriInterface | ||||||
|  |     { | ||||||
|         return $this->website; |         return $this->website; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -312,7 +359,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * Gets a value indicating whether this repository is empty. |      * Gets a value indicating whether this repository is empty. | ||||||
|      * @return bool `true` if this repository is empty, otherwise `false`. |      * @return bool `true` if this repository is empty, otherwise `false`. | ||||||
|      */ |      */ | ||||||
|     function isEmpty(): bool { |     public function isEmpty(): bool | ||||||
|  |     { | ||||||
|         return $this->isEmpty; |         return $this->isEmpty; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -320,7 +368,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * Gets a value indicating whether this repository is a fork. |      * Gets a value indicating whether this repository is a fork. | ||||||
|      * @return bool `true` if this repository is a fork, otherwise `false`. |      * @return bool `true` if this repository is a fork, otherwise `false`. | ||||||
|      */ |      */ | ||||||
|     function isFork(): bool { |     public function isFork(): bool | ||||||
|  |     { | ||||||
|         return $this->isFork; |         return $this->isFork; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -328,7 +377,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * Gets a value indicating whether this repository is a mirror. |      * Gets a value indicating whether this repository is a mirror. | ||||||
|      * @return bool `true` if this repository is a mirror, otherwise `false`. |      * @return bool `true` if this repository is a mirror, otherwise `false`. | ||||||
|      */ |      */ | ||||||
|     function isMirror(): bool { |     public function isMirror(): bool | ||||||
|  |     { | ||||||
|         return $this->isMirror; |         return $this->isMirror; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -336,15 +386,17 @@ class Repository extends AbstractApiModel { | |||||||
|      * Gets a value indicating whether this repository is private. |      * Gets a value indicating whether this repository is private. | ||||||
|      * @return bool `true` if this repository is private, otherwise `false`. |      * @return bool `true` if this repository is private, otherwise `false`. | ||||||
|      */ |      */ | ||||||
|     function isPrivate(): bool { |     public function isPrivate(): bool | ||||||
|  |     { | ||||||
|         return $this->isPrivate; |         return $this->isPrivate; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 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 { |     public function jsonSerialize(): stdClass | ||||||
|  |     { | ||||||
|         return (object) [ |         return (object) [ | ||||||
|             'clone_url' => ($url = $this->getCloneUrl()) ? (string) $url : null, |             'clone_url' => ($url = $this->getCloneUrl()) ? (string) $url : null, | ||||||
|             'created_at' => ($date = $this->getCreatedAt()) ? $date->format('c') : null, |             'created_at' => ($date = $this->getCreatedAt()) ? $date->format('c') : null, | ||||||
| @ -377,17 +429,19 @@ class Repository extends AbstractApiModel { | |||||||
|      * @param UriInterface|null $value The new URL for cloning this repository. |      * @param UriInterface|null $value The new URL for cloning this repository. | ||||||
|      * @return $this This instance. |      * @return $this This instance. | ||||||
|      */ |      */ | ||||||
|     function setCloneUrl(?UriInterface $value): self { |     public function setCloneUrl(?UriInterface $value): self | ||||||
|  |     { | ||||||
|         $this->cloneUrl = $value; |         $this->cloneUrl = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Sets the date the repository was created. |      * Sets the date the repository 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 { |     public function setCreatedAt(?DateTime $value): self | ||||||
|  |     { | ||||||
|         $this->createdAt = $value; |         $this->createdAt = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -397,7 +451,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * @param string $value The new default branch. |      * @param string $value The new default branch. | ||||||
|      * @return $this This instance. |      * @return $this This instance. | ||||||
|      */ |      */ | ||||||
|     function setDefaultBranch(string $value): self { |     public function setDefaultBranch(string $value): self | ||||||
|  |     { | ||||||
|         $this->defaultBranch = $value; |         $this->defaultBranch = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -407,7 +462,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * @param string $value The new repository description. |      * @param string $value The new repository description. | ||||||
|      * @return $this This instance. |      * @return $this This instance. | ||||||
|      */ |      */ | ||||||
|     function setDescription(string $value): self { |     public function setDescription(string $value): self | ||||||
|  |     { | ||||||
|         $this->description = $value; |         $this->description = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -417,7 +473,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * @param bool $value `true` if this repository is empty, otherwise `false`. |      * @param bool $value `true` if this repository is empty, otherwise `false`. | ||||||
|      * @return $this This instance. |      * @return $this This instance. | ||||||
|      */ |      */ | ||||||
|     function setEmpty(bool $value): self { |     public function setEmpty(bool $value): self | ||||||
|  |     { | ||||||
|         $this->isEmpty = $value; |         $this->isEmpty = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -427,7 +484,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * @param bool $value `true` if this repository is a fork, otherwise `false`. |      * @param bool $value `true` if this repository is a fork, otherwise `false`. | ||||||
|      * @return $this This instance. |      * @return $this This instance. | ||||||
|      */ |      */ | ||||||
|     function setFork(bool $value): self { |     public function setFork(bool $value): self | ||||||
|  |     { | ||||||
|         $this->isFork = $value; |         $this->isFork = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -437,7 +495,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * @param int $value The new number of forks. |      * @param int $value The new number of forks. | ||||||
|      * @return $this This instance. |      * @return $this This instance. | ||||||
|      */ |      */ | ||||||
|     function setForksCount(int $value): self { |     public function setForksCount(int $value): self | ||||||
|  |     { | ||||||
|         $this->forksCount = max(0, $value); |         $this->forksCount = max(0, $value); | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -447,7 +506,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * @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 { |     public function setFullName(string $value): self | ||||||
|  |     { | ||||||
|         $this->fullName = $value; |         $this->fullName = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -457,7 +517,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * @param UriInterface|null $value The new Gitea URL. |      * @param UriInterface|null $value The new Gitea URL. | ||||||
|      * @return $this This instance. |      * @return $this This instance. | ||||||
|      */ |      */ | ||||||
|     function setHtmlUrl(?UriInterface $value): self { |     public function setHtmlUrl(?UriInterface $value): self | ||||||
|  |     { | ||||||
|         $this->htmlUrl = $value; |         $this->htmlUrl = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -467,7 +528,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * @param bool $value `true` if this repository is a mirror, otherwise `false`. |      * @param bool $value `true` if this repository is a mirror, otherwise `false`. | ||||||
|      * @return $this This instance. |      * @return $this This instance. | ||||||
|      */ |      */ | ||||||
|     function setMirror(bool $value): self { |     public function setMirror(bool $value): self | ||||||
|  |     { | ||||||
|         $this->isMirror = $value; |         $this->isMirror = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -477,7 +539,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * @param string $value The new repository name. |      * @param string $value The new repository name. | ||||||
|      * @return $this This instance. |      * @return $this This instance. | ||||||
|      */ |      */ | ||||||
|     function setName(string $value): self { |     public function setName(string $value): self | ||||||
|  |     { | ||||||
|         $this->name = $value; |         $this->name = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -487,7 +550,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * @param int $value The new number of open issues. |      * @param int $value The new number of open issues. | ||||||
|      * @return $this This instance. |      * @return $this This instance. | ||||||
|      */ |      */ | ||||||
|     function setOpenIssuesCount(int $value): self { |     public function setOpenIssuesCount(int $value): self | ||||||
|  |     { | ||||||
|         $this->openIssuesCount = max(0, $value); |         $this->openIssuesCount = max(0, $value); | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -497,7 +561,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * @param User|null $value The new owner. |      * @param User|null $value The new owner. | ||||||
|      * @return $this This instance. |      * @return $this This instance. | ||||||
|      */ |      */ | ||||||
|     function setOwner(?Owner $value): self { |     public function setOwner(?Owner $value): self | ||||||
|  |     { | ||||||
|         $this->owner = $value; |         $this->owner = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -507,7 +572,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * @param Repository|null $value The new parent repository. |      * @param Repository|null $value The new parent repository. | ||||||
|      * @return $this This instance. |      * @return $this This instance. | ||||||
|      */ |      */ | ||||||
|     function setParent(?Repository $value): self { |     public function setParent(?Repository $value): self | ||||||
|  |     { | ||||||
|         $this->parent = $value; |         $this->parent = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -517,7 +583,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * @param Permission|null $value The new permissions. |      * @param Permission|null $value The new permissions. | ||||||
|      * @return $this This instance. |      * @return $this This instance. | ||||||
|      */ |      */ | ||||||
|     function setPermissions(?Permission $value): self { |     public function setPermissions(?Permission $value): self | ||||||
|  |     { | ||||||
|         $this->permissions = $value; |         $this->permissions = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -527,7 +594,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * @param bool $value `true` if this repository is private, otherwise `false`. |      * @param bool $value `true` if this repository is private, otherwise `false`. | ||||||
|      * @return $this This instance. |      * @return $this This instance. | ||||||
|      */ |      */ | ||||||
|     function setPrivate(bool $value): self { |     public function setPrivate(bool $value): self | ||||||
|  |     { | ||||||
|         $this->isPrivate = $value; |         $this->isPrivate = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -537,7 +605,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * @param int $value The new repository size, in kilobytes. |      * @param int $value The new repository size, in kilobytes. | ||||||
|      * @return $this This instance. |      * @return $this This instance. | ||||||
|      */ |      */ | ||||||
|     function setSize(int $value): self { |     public function setSize(int $value): self | ||||||
|  |     { | ||||||
|         $this->size = $value; |         $this->size = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -547,7 +616,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * @param UriInterface|null $value The new URL for cloning this repository. |      * @param UriInterface|null $value The new URL for cloning this repository. | ||||||
|      * @return $this This instance. |      * @return $this This instance. | ||||||
|      */ |      */ | ||||||
|     function setSshUrl(?UriInterface $value): self { |     public function setSshUrl(?UriInterface $value): self | ||||||
|  |     { | ||||||
|         $this->sshUrl = $value; |         $this->sshUrl = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -557,17 +627,19 @@ class Repository extends AbstractApiModel { | |||||||
|      * @param int $value The new number of stars. |      * @param int $value The new number of stars. | ||||||
|      * @return $this This instance. |      * @return $this This instance. | ||||||
|      */ |      */ | ||||||
|     function setStarsCount(int $value): self { |     public function setStarsCount(int $value): self | ||||||
|  |     { | ||||||
|         $this->starsCount = max(0, $value); |         $this->starsCount = max(0, $value); | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Sets the date the repository was updated. |      * Sets the date the repository was updated. | ||||||
|      * @param \DateTime|null $value The new date of update. |      * @param DateTime|null $value The new date of update. | ||||||
|      * @return $this This instance. |      * @return $this This instance. | ||||||
|      */ |      */ | ||||||
|     function setUpdatedAt(?\DateTime $value): self { |     public function setUpdatedAt(?DateTime $value): self | ||||||
|  |     { | ||||||
|         $this->updatedAt = $value; |         $this->updatedAt = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -577,7 +649,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * @param int $value The new number of watchers. |      * @param int $value The new number of watchers. | ||||||
|      * @return $this This instance. |      * @return $this This instance. | ||||||
|      */ |      */ | ||||||
|     function setWatchersCount(int $value): self { |     public function setWatchersCount(int $value): self | ||||||
|  |     { | ||||||
|         $this->watchersCount = max(0, $value); |         $this->watchersCount = max(0, $value); | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -587,7 +660,8 @@ class Repository extends AbstractApiModel { | |||||||
|      * @param UriInterface|null $value The new repository website. |      * @param UriInterface|null $value The new repository website. | ||||||
|      * @return $this This instance. |      * @return $this This instance. | ||||||
|      */ |      */ | ||||||
|     function setWebsite(?UriInterface $value): self { |     public function setWebsite(?UriInterface $value): self | ||||||
|  |     { | ||||||
|         $this->website = $value; |         $this->website = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -644,5 +718,4 @@ class Repository extends AbstractApiModel { | |||||||
|             return $tagsApi->fromRepository($owner->getUsername(), $this->getName()); |             return $tagsApi->fromRepository($owner->getUsername(), $this->getName()); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,9 +1,14 @@ | |||||||
| <?php declare(strict_types=1); | <?php | ||||||
|  | declare(strict_types=1); | ||||||
|  |  | ||||||
| namespace Gitea\Model; | namespace Gitea\Model; | ||||||
|  |  | ||||||
| /** Wraps the version of the Gitea server. */ | use stdClass; | ||||||
| class ServerVersion implements \JsonSerializable { | use JsonSerializable; | ||||||
|  |  | ||||||
|  | /** Wraps the version of the Gitea server. */ | ||||||
|  | class ServerVersion implements JsonSerializable | ||||||
|  | { | ||||||
|     /** @var string The version number. */ |     /** @var string The version number. */ | ||||||
|     private $version; |     private $version; | ||||||
|  |  | ||||||
| @ -11,7 +16,8 @@ class ServerVersion implements \JsonSerializable { | |||||||
|      * 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) { |     public function __construct(string $version) | ||||||
|  |     { | ||||||
|         $this->version = $version; |         $this->version = $version; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -20,7 +26,8 @@ class ServerVersion implements \JsonSerializable { | |||||||
|      * @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 { |     public 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 : ''); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -28,15 +35,17 @@ class ServerVersion implements \JsonSerializable { | |||||||
|      * Gets the version number. |      * Gets the version number. | ||||||
|      * @return string The version number. |      * @return string The version number. | ||||||
|      */ |      */ | ||||||
|     function getVersion(): string { |     public 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 { |     public function jsonSerialize(): stdClass | ||||||
|  |     { | ||||||
|         return (object) ['version' => $this->getVersion()]; |         return (object) ['version' => $this->getVersion()]; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -7,8 +7,8 @@ namespace Gitea\Model; | |||||||
| use MyCLabs\Enum\Enum; | use MyCLabs\Enum\Enum; | ||||||
|  |  | ||||||
| /** Defines the state of a Gitea status. */ | /** Defines the state of a Gitea status. */ | ||||||
| final class StatusState extends Enum { | final class StatusState extends Enum | ||||||
|  | { | ||||||
|     /** @var string The status is an error. */ |     /** @var string The status is an error. */ | ||||||
|     const error = 'error'; |     const error = 'error'; | ||||||
|  |  | ||||||
|  | |||||||
| @ -7,23 +7,24 @@ use Psr\Http\Message\UriInterface; | |||||||
|  |  | ||||||
| use Gitea\Client; | use Gitea\Client; | ||||||
|  |  | ||||||
| use \InvalidArgumentException; | use stdClass; | ||||||
|  | use InvalidArgumentException; | ||||||
|  |  | ||||||
| use Gitea\Model\Abstracts\AbstractApiModel; | use Gitea\Model\Abstracts\AbstractApiModel; | ||||||
|  |  | ||||||
| /** Represents a Gitea tag. */ | /** Represents a Gitea tag. */ | ||||||
| class Tag extends AbstractApiModel { | class Tag extends AbstractApiModel | ||||||
|  | { | ||||||
|     /** @var int The tag identifier. */ |     /** @var int The tag identifier. */ | ||||||
|     private $id = -1; |     private $id = -1; | ||||||
|  |  | ||||||
|     /** @var string The tag's name. */ |     /** @var string The tag's name. */ | ||||||
|     private $name = ''; |     private $name = ''; | ||||||
|  |  | ||||||
|     /** @var string The tarball URL for the tag */ |     /** @var UriInterface The tarball URL for the tag */ | ||||||
|     private $tarballURL; |     private $tarballURL; | ||||||
|  |  | ||||||
|     /** @var string The zipball URL for the tag */ |     /** @var UriInterface The zipball URL for the tag */ | ||||||
|     private $zipballURL; |     private $zipballURL; | ||||||
|  |  | ||||||
|     /** @var int The commit information for the tag */ |     /** @var int The commit information for the tag */ | ||||||
| @ -39,7 +40,8 @@ class Tag extends AbstractApiModel { | |||||||
|      * @param int|string $id The tag identifier |      * @param int|string $id The tag identifier | ||||||
|      * @param string $name The tag name |      * @param string $name The tag name | ||||||
|      */ |      */ | ||||||
|     public function __construct(Client &$client , ?object $caller, ...$args) { |     public function __construct(Client &$client, ?object $caller, ...$args) | ||||||
|  |     { | ||||||
|         parent::__construct($client, $caller, $args); |         parent::__construct($client, $caller, $args); | ||||||
|         if (count($args) >= 2) { |         if (count($args) >= 2) { | ||||||
|             $id = $args[0]; |             $id = $args[0]; | ||||||
| @ -67,7 +69,8 @@ class Tag extends AbstractApiModel { | |||||||
|      * @param object $map A JSON map representing an tag. |      * @param object $map A JSON map representing an tag. | ||||||
|      * @return static The instance corresponding to the specified JSON map. |      * @return static The instance corresponding to the specified JSON map. | ||||||
|      */ |      */ | ||||||
|     static function fromJson(object &$client , ?object $caller, object $map): self { |     public static function fromJson(object &$client, ?object $caller, object $map): self | ||||||
|  |     { | ||||||
|         $newTag = new static( |         $newTag = new static( | ||||||
|             $client, |             $client, | ||||||
|             $caller, |             $caller, | ||||||
| @ -85,9 +88,10 @@ class Tag extends AbstractApiModel { | |||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 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 { |     public function jsonSerialize(): stdClass | ||||||
|  |     { | ||||||
|         return (object) [ |         return (object) [ | ||||||
|             'id' => $this->getId(), |             'id' => $this->getId(), | ||||||
|             'name' => $this->getName(), |             'name' => $this->getName(), | ||||||
| @ -104,55 +108,65 @@ class Tag extends AbstractApiModel { | |||||||
|      * Gets the tag identifier. |      * Gets the tag identifier. | ||||||
|      * @return int The tag identifier. |      * @return int The tag identifier. | ||||||
|      */ |      */ | ||||||
|     function getId(): string { |     public function getId(): string | ||||||
|  |     { | ||||||
|         return $this->id; |         return $this->id; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getName(): string { |     public function getName(): string | ||||||
|  |     { | ||||||
|         return $this->name; |         return $this->name; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function setName($name): self { |     public function setName($name): self | ||||||
|  |     { | ||||||
|         $this->name = $name; |         $this->name = $name; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getTarballURL(): ?UriInterface { |     public function getTarballURL(): ?UriInterface | ||||||
|  |     { | ||||||
|         return $this->tarballURL; |         return $this->tarballURL; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function setTarballURL(?UriInterface $url): self { |     public function setTarballURL(?UriInterface $url): self | ||||||
|  |     { | ||||||
|         $this->tarballURL = $url; |         $this->tarballURL = $url; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getZipballURL(): ?UriInterface { |     public function getZipballURL(): ?UriInterface | ||||||
|  |     { | ||||||
|         return $this->zipballURL; |         return $this->zipballURL; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function setZipballURL(?UriInterface $url): self { |     public function setZipballURL(?UriInterface $url): self | ||||||
|  |     { | ||||||
|         $this->zipballURL = $url; |         $this->zipballURL = $url; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getCommitSha(): string { |     public function getCommitSha(): string | ||||||
|  |     { | ||||||
|         $commit = $this->commit; |         $commit = $this->commit; | ||||||
|         return $commit["sha"]; |         return $commit["sha"]; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function setCommitSha(string $string): self { |     public function setCommitSha(string $string): self | ||||||
|  |     { | ||||||
|         $this->commit["sha"] = $string; |         $this->commit["sha"] = $string; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getCommitUrl(): ?uri { |     public function getCommitUrl(): ?uri | ||||||
|  |     { | ||||||
|         $commit = $this->commit; |         $commit = $this->commit; | ||||||
|         return $commit["url"]; |         return $commit["url"]; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function setCommitUrl(?uri $url): self { |     public function setCommitUrl(?uri $url): self | ||||||
|  |     { | ||||||
|         $this->commit["url"] = $url; |         $this->commit["url"] = $url; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,9 +1,14 @@ | |||||||
| <?php declare(strict_types=1); | <?php | ||||||
|  | declare(strict_types=1); | ||||||
|  |  | ||||||
| namespace Gitea\Model; | namespace Gitea\Model; | ||||||
|  |  | ||||||
| /** Represents a team in an organization. */ | use stdClass; | ||||||
| class Team implements \JsonSerializable { | use JsonSerializable; | ||||||
|  |  | ||||||
|  | /** Represents a team in an organization. */ | ||||||
|  | class Team implements JsonSerializable | ||||||
|  | { | ||||||
|     /** @var string The team description. */ |     /** @var string The team description. */ | ||||||
|     private $description = ''; |     private $description = ''; | ||||||
|  |  | ||||||
| @ -21,7 +26,8 @@ class Team implements \JsonSerializable { | |||||||
|      * @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) { |     public function __construct(int $id, string $name) | ||||||
|  |     { | ||||||
|         $this->id = $id; |         $this->id = $id; | ||||||
|         $this->setName($name); |         $this->setName($name); | ||||||
|     } |     } | ||||||
| @ -31,7 +37,8 @@ class Team implements \JsonSerializable { | |||||||
|      * @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 { |     public static function fromJson(object $map): self | ||||||
|  |     { | ||||||
|         return (new static(isset($map->id) && is_numeric($map->id) ? $map->id : -1, isset($map->name) && is_string($map->name) ? $map->name : '')) |         return (new static(isset($map->id) && is_numeric($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); | ||||||
| @ -41,7 +48,8 @@ class Team implements \JsonSerializable { | |||||||
|      * Gets the team description. |      * Gets the team description. | ||||||
|      * @return string The team description. |      * @return string The team description. | ||||||
|      */ |      */ | ||||||
|     function getDescription(): string { |     public function getDescription(): string | ||||||
|  |     { | ||||||
|         return $this->description; |         return $this->description; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -49,7 +57,8 @@ class Team implements \JsonSerializable { | |||||||
|      * Gets the team identifier. |      * Gets the team identifier. | ||||||
|      * @return int The team identifier. |      * @return int The team identifier. | ||||||
|      */ |      */ | ||||||
|     function getId(): int { |     public function getId(): int | ||||||
|  |     { | ||||||
|         return $this->id; |         return $this->id; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -57,7 +66,8 @@ class Team implements \JsonSerializable { | |||||||
|      * Gets the team name. |      * Gets the team name. | ||||||
|      * @return string The team name. |      * @return string The team name. | ||||||
|      */ |      */ | ||||||
|     function getName(): string { |     public function getName(): string | ||||||
|  |     { | ||||||
|         return $this->name; |         return $this->name; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -65,15 +75,17 @@ class Team implements \JsonSerializable { | |||||||
|      * Gets the team permission. |      * Gets the team permission. | ||||||
|      * @return string The team permission. |      * @return string The team permission. | ||||||
|      */ |      */ | ||||||
|     function getPermission(): string { |     public 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 { |     public function jsonSerialize(): stdClass | ||||||
|  |     { | ||||||
|         return (object) [ |         return (object) [ | ||||||
|             'description' => $this->getDescription(), |             'description' => $this->getDescription(), | ||||||
|             'id' => $this->getId(), |             'id' => $this->getId(), | ||||||
| @ -87,7 +99,8 @@ class Team implements \JsonSerializable { | |||||||
|      * @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 { |     public function setDescription(string $value): self | ||||||
|  |     { | ||||||
|         $this->description = $value; |         $this->description = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -97,7 +110,8 @@ class Team implements \JsonSerializable { | |||||||
|      * @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 { |     public function setName(string $value): self | ||||||
|  |     { | ||||||
|         $this->name = $value; |         $this->name = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -107,7 +121,8 @@ class Team implements \JsonSerializable { | |||||||
|      * @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 { |     public function setPermission(string $value): self | ||||||
|  |     { | ||||||
|         $this->permission = TeamPermission::coerce($value, TeamPermission::none); |         $this->permission = TeamPermission::coerce($value, TeamPermission::none); | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -1,11 +1,13 @@ | |||||||
| <?php declare(strict_types=1); | <?php | ||||||
|  | declare(strict_types=1); | ||||||
|  |  | ||||||
| namespace Gitea\Model; | namespace Gitea\Model; | ||||||
|  |  | ||||||
| use MyCLabs\Enum\Enum; | use MyCLabs\Enum\Enum; | ||||||
|  |  | ||||||
| /** Defines the permission of a team. */ | /** Defines the permission of a team. */ | ||||||
| final class TeamPermission extends Enum { | final class TeamPermission extends Enum | ||||||
|  | { | ||||||
|     /** @var string The team has the administrator permission. */ |     /** @var string The team has the administrator permission. */ | ||||||
|     const admin = 'admin'; |     const admin = 'admin'; | ||||||
|  |  | ||||||
|  | |||||||
| @ -1,10 +1,16 @@ | |||||||
| <?php declare(strict_types=1); | <?php | ||||||
|  | declare(strict_types=1); | ||||||
|  |  | ||||||
| namespace Gitea\Model; | namespace Gitea\Model; | ||||||
|  |  | ||||||
| /** Represents the worked time for an issue or pull request. */ | use stdClass; | ||||||
| class TrackedTime implements \JsonSerializable { | use DateTime; | ||||||
|  | use JsonSerializable; | ||||||
|  |  | ||||||
|     /** @var \DateTime|null The date the entry was created. */ | /** 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; |     private $createdAt; | ||||||
|  |  | ||||||
|     /** @var int The entry identifier. */ |     /** @var int The entry identifier. */ | ||||||
| @ -24,7 +30,8 @@ class TrackedTime implements \JsonSerializable { | |||||||
|      * @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) { |     public function __construct(int $id, int $time) | ||||||
|  |     { | ||||||
|         $this->id = $id; |         $this->id = $id; | ||||||
|         $this->setTime($time); |         $this->setTime($time); | ||||||
|     } |     } | ||||||
| @ -34,18 +41,24 @@ class TrackedTime implements \JsonSerializable { | |||||||
|      * @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 { |     public static function fromJson(object $map): self | ||||||
|         return (new static(isset($map->id) && is_numeric($map->id) ? $map->id : -1, isset($map->time) && is_numeric($map->time) ? $map->time : 0)) |     { | ||||||
|             ->setCreatedAt(isset($map->created) && is_string($map->created) ? new \DateTime($map->created) : null) |         return ( | ||||||
|  |             new static(isset($map->id) | ||||||
|  |             && is_numeric($map->id) ? $map->id : -1, isset($map->time) | ||||||
|  |             && is_numeric($map->time) ? $map->time : 0) | ||||||
|  |         ) | ||||||
|  |         ->setCreatedAt(isset($map->created) && is_string($map->created) ? new DateTime($map->created) : null) | ||||||
|         ->setIssueId(isset($map->issue_id) && is_numeric($map->issue_id) ? $map->issue_id : -1) |         ->setIssueId(isset($map->issue_id) && is_numeric($map->issue_id) ? $map->issue_id : -1) | ||||||
|         ->setUserId(isset($map->user_id) && is_numeric($map->user_id) ? $map->user_id : -1); |         ->setUserId(isset($map->user_id) && is_numeric($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 { |     public function getCreatedAt(): ?DateTime | ||||||
|  |     { | ||||||
|         return $this->createdAt; |         return $this->createdAt; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -53,7 +66,8 @@ class TrackedTime implements \JsonSerializable { | |||||||
|      * Gets the entry identifier. |      * Gets the entry identifier. | ||||||
|      * @return int The entry identifier. |      * @return int The entry identifier. | ||||||
|      */ |      */ | ||||||
|     function getId(): int { |     public function getId(): int | ||||||
|  |     { | ||||||
|         return $this->id; |         return $this->id; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -61,7 +75,8 @@ class TrackedTime implements \JsonSerializable { | |||||||
|      * 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 { |     public function getIssueId(): int | ||||||
|  |     { | ||||||
|         return $this->issueId; |         return $this->issueId; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -69,7 +84,8 @@ class TrackedTime implements \JsonSerializable { | |||||||
|      * 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 { |     public function getTime(): int | ||||||
|  |     { | ||||||
|         return $this->time; |         return $this->time; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -77,15 +93,17 @@ class TrackedTime implements \JsonSerializable { | |||||||
|      * 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 { |     public 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 { |     public 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(), | ||||||
| @ -97,10 +115,11 @@ class TrackedTime implements \JsonSerializable { | |||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 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 { |     public function setCreatedAt(?DateTime $value): self | ||||||
|  |     { | ||||||
|         $this->createdAt = $value; |         $this->createdAt = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -110,7 +129,8 @@ class TrackedTime implements \JsonSerializable { | |||||||
|      * @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 { |     public function setIssueId(int $value): self | ||||||
|  |     { | ||||||
|         $this->issueId = $value; |         $this->issueId = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -120,7 +140,8 @@ class TrackedTime implements \JsonSerializable { | |||||||
|      * @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 { |     public function setTime(int $value): self | ||||||
|  |     { | ||||||
|         $this->time = $value; |         $this->time = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -130,7 +151,8 @@ class TrackedTime implements \JsonSerializable { | |||||||
|      * @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 { |     public function setUserId(int $value): self | ||||||
|  |     { | ||||||
|         $this->userId = $value; |         $this->userId = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -1,12 +1,17 @@ | |||||||
| <?php declare(strict_types=1); | <?php | ||||||
|  | declare(strict_types=1); | ||||||
|  |  | ||||||
| namespace Gitea\Model; | namespace Gitea\Model; | ||||||
|  |  | ||||||
| use GuzzleHttp\Psr7\{Uri}; | use GuzzleHttp\Psr7\{Uri}; | ||||||
| use Psr\Http\Message\{UriInterface}; | use Psr\Http\Message\{UriInterface}; | ||||||
|  |  | ||||||
| /** Represents a Gitea user. */ | use stdClass; | ||||||
| class User implements \JsonSerializable { | use JsonSerializable; | ||||||
|  |  | ||||||
|  | /** Represents a Gitea user. */ | ||||||
|  | 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; | ||||||
|  |  | ||||||
| @ -30,7 +35,8 @@ class User implements \JsonSerializable { | |||||||
|      * @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) { |     public function __construct(int $id, string $login) | ||||||
|  |     { | ||||||
|         $this->id = $id; |         $this->id = $id; | ||||||
|         $this->setLogin($login); |         $this->setLogin($login); | ||||||
|     } |     } | ||||||
| @ -40,8 +46,13 @@ class User implements \JsonSerializable { | |||||||
|      * @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 { |     public static function fromJson(object $map): self | ||||||
|         return (new static(isset($map->id) && is_numeric($map->id) ? $map->id : -1, isset($map->login) && is_string($map->login) ? $map->login : '')) |     { | ||||||
|  |         return ( | ||||||
|  |             new static(isset($map->id) | ||||||
|  |             && is_numeric($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 : '') | ||||||
| @ -52,7 +63,8 @@ class User implements \JsonSerializable { | |||||||
|      * 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 { |     public function getAvatarUrl(): ?UriInterface | ||||||
|  |     { | ||||||
|         return $this->avatarUrl; |         return $this->avatarUrl; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -60,7 +72,8 @@ class User implements \JsonSerializable { | |||||||
|      * Gets the mail address. |      * Gets the mail address. | ||||||
|      * @return string The mail address. |      * @return string The mail address. | ||||||
|      */ |      */ | ||||||
|     function getEmail(): string { |     public function getEmail(): string | ||||||
|  |     { | ||||||
|         return $this->email; |         return $this->email; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -68,7 +81,8 @@ class User implements \JsonSerializable { | |||||||
|      * Gets the full name. |      * Gets the full name. | ||||||
|      * @return string The full name. |      * @return string The full name. | ||||||
|      */ |      */ | ||||||
|     function getFullName(): string { |     public function getFullName(): string | ||||||
|  |     { | ||||||
|         return $this->fullName; |         return $this->fullName; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -76,7 +90,8 @@ class User implements \JsonSerializable { | |||||||
|      * Gets the user identifier. |      * Gets the user identifier. | ||||||
|      * @return int The user identifier. |      * @return int The user identifier. | ||||||
|      */ |      */ | ||||||
|     function getId(): int { |     public function getId(): int | ||||||
|  |     { | ||||||
|         return $this->id; |         return $this->id; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -84,7 +99,8 @@ class User implements \JsonSerializable { | |||||||
|      * Gets the user locale. |      * Gets the user locale. | ||||||
|      * @return string The user locale. |      * @return string The user locale. | ||||||
|      */ |      */ | ||||||
|     function getLanguage(): string { |     public function getLanguage(): string | ||||||
|  |     { | ||||||
|         return $this->language; |         return $this->language; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -92,15 +108,17 @@ class User implements \JsonSerializable { | |||||||
|      * 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 { |     public 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 { |     public 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(), | ||||||
| @ -116,7 +134,8 @@ class User implements \JsonSerializable { | |||||||
|      * @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 { |     public function setAvatarUrl(?UriInterface $value): self | ||||||
|  |     { | ||||||
|         $this->avatarUrl = $value; |         $this->avatarUrl = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -126,7 +145,8 @@ class User implements \JsonSerializable { | |||||||
|      * @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 { |     public function setEmail(string $value): self | ||||||
|  |     { | ||||||
|         $this->email = $value; |         $this->email = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -136,7 +156,8 @@ class User implements \JsonSerializable { | |||||||
|      * @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 { |     public function setFullName(string $value): self | ||||||
|  |     { | ||||||
|         $this->fullName = $value; |         $this->fullName = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -146,7 +167,8 @@ class User implements \JsonSerializable { | |||||||
|      * @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 { |     public function setLanguage(string $value): self | ||||||
|  |     { | ||||||
|         $this->language = $value; |         $this->language = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -156,7 +178,8 @@ class User implements \JsonSerializable { | |||||||
|      * @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 { |     public function setLogin(string $value): self | ||||||
|  |     { | ||||||
|         $this->login = $value; |         $this->login = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -9,11 +9,13 @@ use GuzzleHttp\Exception\ClientException; | |||||||
| use GuzzleHttp\Psr7\Uri; | use GuzzleHttp\Psr7\Uri; | ||||||
| use Psr\Http\Message\UriInterface; | use Psr\Http\Message\UriInterface; | ||||||
|  |  | ||||||
|  | use stdClass; | ||||||
|  |  | ||||||
| use Gitea\Model\Abstracts\AbstractApiModel; | use Gitea\Model\Abstracts\AbstractApiModel; | ||||||
|  |  | ||||||
| /** Represents a Gitea push event. */ | /** Represents a Gitea push event. */ | ||||||
| class PushEvent extends AbstractApiModel { | class PushEvent extends AbstractApiModel | ||||||
|  | { | ||||||
|     /** @var string The hash of the new Git revision. */ |     /** @var string The hash of the new Git revision. */ | ||||||
|     private $after = ''; |     private $after = ''; | ||||||
|  |  | ||||||
| @ -42,8 +44,9 @@ class PushEvent extends AbstractApiModel { | |||||||
|     private $sender; |     private $sender; | ||||||
|  |  | ||||||
|     /** Creates a new event. */ |     /** Creates a new event. */ | ||||||
|     function __construct(Client &$client, ?object $caller, ...$args) { |     public function __construct(Client &$client, ?object $caller, ...$args) | ||||||
|         $this->commits = new \ArrayObject; |     { | ||||||
|  |         $this->commits = new \ArrayObject(); | ||||||
|         parent::__construct($client, $caller, ...$args); |         parent::__construct($client, $caller, ...$args); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -93,7 +96,9 @@ class PushEvent extends AbstractApiModel { | |||||||
|  |  | ||||||
|             // check payload signature against header signature |             // check payload signature against header signature | ||||||
|             if ($headerSignature != $payload_signature) { |             if ($headerSignature != $payload_signature) { | ||||||
|                 throw new \RuntimeException("FAILED: Access Denied - The push event's secret does not match the expected secret"); |                 throw new \RuntimeException( | ||||||
|  |                     "FAILED: Access Denied - The push event's secret does not match the expected secret" | ||||||
|  |                 ); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @ -105,7 +110,8 @@ class PushEvent extends AbstractApiModel { | |||||||
|      * @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 &$client, ?object $caller, object $map): self { |     public static function fromJson(object &$client, ?object $caller, object $map): self | ||||||
|  |     { | ||||||
|         $newEvent = new static( |         $newEvent = new static( | ||||||
|             $client, |             $client, | ||||||
|             $caller |             $caller | ||||||
| @ -119,7 +125,7 @@ class PushEvent extends AbstractApiModel { | |||||||
|         ->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($client, null, $map->sender) : null); |         ->setSender(isset($map->sender) && is_object($map->sender) ? User::fromJson($client, null, $map->sender) : null); | ||||||
|  |  | ||||||
|         if(isset($map->commits) && is_array($map->commits)) { |         if (isset($map->commits) && is_array($map->commits)) { | ||||||
|             $commitsArray = []; |             $commitsArray = []; | ||||||
|             foreach ($map->commits as $commit) { |             foreach ($map->commits as $commit) { | ||||||
|                 $commitsArray[] = PayloadCommit::fromJson($client, null, $commit); |                 $commitsArray[] = PayloadCommit::fromJson($client, null, $commit); | ||||||
| @ -134,7 +140,8 @@ class PushEvent extends AbstractApiModel { | |||||||
|      * 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 { |     public function getAfter(): string | ||||||
|  |     { | ||||||
|         return $this->after; |         return $this->after; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -142,7 +149,8 @@ class PushEvent extends AbstractApiModel { | |||||||
|      * 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 { |     public function getBefore(): string | ||||||
|  |     { | ||||||
|         return $this->before; |         return $this->before; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -150,7 +158,8 @@ class PushEvent extends AbstractApiModel { | |||||||
|      * Gets the revision commits. |      * Gets the revision commits. | ||||||
|      * @return \ArrayObject The revision commits. |      * @return \ArrayObject The revision commits. | ||||||
|      */ |      */ | ||||||
|     function getCommits(): \ArrayObject { |     public function getCommits(): \ArrayObject | ||||||
|  |     { | ||||||
|         return $this->commits; |         return $this->commits; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -158,7 +167,8 @@ class PushEvent extends AbstractApiModel { | |||||||
|      * 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 { |     public function getCompareUrl(): ?UriInterface | ||||||
|  |     { | ||||||
|         return $this->compareUrl; |         return $this->compareUrl; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -166,7 +176,8 @@ class PushEvent extends AbstractApiModel { | |||||||
|      * 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 { |     public function getPusher(): ?User | ||||||
|  |     { | ||||||
|         return $this->pusher; |         return $this->pusher; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -174,7 +185,8 @@ class PushEvent extends AbstractApiModel { | |||||||
|      * Gets the Git reference. |      * Gets the Git reference. | ||||||
|      * @return string The Git reference. |      * @return string The Git reference. | ||||||
|      */ |      */ | ||||||
|     function getRef(): string { |     public function getRef(): string | ||||||
|  |     { | ||||||
|         return $this->ref; |         return $this->ref; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -182,7 +194,8 @@ class PushEvent extends AbstractApiModel { | |||||||
|      * 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 { |     public function getRepository(): ?Repository | ||||||
|  |     { | ||||||
|         return $this->repository; |         return $this->repository; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -190,7 +203,8 @@ class PushEvent extends AbstractApiModel { | |||||||
|      * 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 { |     public function getSecret(): string | ||||||
|  |     { | ||||||
|         return $this->secret; |         return $this->secret; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -198,20 +212,27 @@ class PushEvent extends AbstractApiModel { | |||||||
|      * 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 { |     public 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 { |     public 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, | ||||||
| @ -224,7 +245,8 @@ class PushEvent extends AbstractApiModel { | |||||||
|      * @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 { |     public function setAfter(string $value): self | ||||||
|  |     { | ||||||
|         $this->after = $value; |         $this->after = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -234,7 +256,8 @@ class PushEvent extends AbstractApiModel { | |||||||
|      * @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 { |     public function setBefore(string $value): self | ||||||
|  |     { | ||||||
|         $this->before = $value; |         $this->before = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -244,7 +267,8 @@ class PushEvent extends AbstractApiModel { | |||||||
|      * @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 { |     public function setCommits(array $values): self | ||||||
|  |     { | ||||||
|         $this->getCommits()->exchangeArray($values); |         $this->getCommits()->exchangeArray($values); | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -254,7 +278,8 @@ class PushEvent extends AbstractApiModel { | |||||||
|      * @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 { |     public function setCompareUrl(?UriInterface $value): self | ||||||
|  |     { | ||||||
|         $this->compareUrl = $value; |         $this->compareUrl = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -264,7 +289,8 @@ class PushEvent extends AbstractApiModel { | |||||||
|      * @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 { |     public function setPusher(?User $value): self | ||||||
|  |     { | ||||||
|         $this->pusher = $value; |         $this->pusher = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -274,7 +300,8 @@ class PushEvent extends AbstractApiModel { | |||||||
|      * @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 { |     public function setRef(string $value): self | ||||||
|  |     { | ||||||
|         $this->ref = $value; |         $this->ref = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -284,7 +311,8 @@ class PushEvent extends AbstractApiModel { | |||||||
|      * @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 { |     public function setRepository(?Repository $value): self | ||||||
|  |     { | ||||||
|         $this->repository = $value; |         $this->repository = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -294,7 +322,8 @@ class PushEvent extends AbstractApiModel { | |||||||
|      * @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 { |     public function setSecret(string $value): self | ||||||
|  |     { | ||||||
|         $this->secret = $value; |         $this->secret = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
| @ -304,7 +333,8 @@ class PushEvent extends AbstractApiModel { | |||||||
|      * @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 { |     public function setSender(?User $value): self | ||||||
|  |     { | ||||||
|         $this->sender = $value; |         $this->sender = $value; | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -70,7 +70,7 @@ if ($repository) { | |||||||
|             if ($foundObj) { |             if ($foundObj) { | ||||||
|                 print("Repository class found \n"); |                 print("Repository class found \n"); | ||||||
|                 print("Type: ".get_class($foundObj)." \n"); |                 print("Type: ".get_class($foundObj)." \n"); | ||||||
|             } else{ |             } else { | ||||||
|                 print("Repository class NOT found \n"); |                 print("Repository class NOT found \n"); | ||||||
|             } |             } | ||||||
|             print("\n\n"); |             print("\n\n"); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	