mirror of
https://github.com/sitelease/sugar-cube-client.git
synced 2025-10-29 11:02:30 +01:00
Altered PSR-12 update
This commit is contained in:
@ -2,11 +2,9 @@
|
||||
|
||||
namespace Gitea\Api\Abstracts;
|
||||
|
||||
use GuzzleHttp\Exception\ServerException;
|
||||
|
||||
use Gitea\Client;
|
||||
use GuzzleHttp\Exception\ServerException;
|
||||
use Gitea\Collections\ApiItemCollection;
|
||||
|
||||
use Gitea\Api\Abstracts\AbstractApiRequester;
|
||||
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
|
||||
* @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");
|
||||
return false;
|
||||
}
|
||||
@ -61,7 +60,7 @@ abstract class AbstractAllApiRequester extends AbstractApiRequester implements A
|
||||
$maxPageCount = $this->getMaxPageCount();
|
||||
$itemsPerPage = $this->getItemsPerPage();
|
||||
// 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);
|
||||
if ($searchItemsCollection && $searchItemsCollection->count() > 0) {
|
||||
$searchItemsArray = $searchItemsCollection->toArray();
|
||||
@ -73,12 +72,13 @@ abstract class AbstractAllApiRequester extends AbstractApiRequester implements A
|
||||
return new ApiItemCollection($allItems);
|
||||
}
|
||||
|
||||
public function getMaxPageCount() {
|
||||
public function getMaxPageCount()
|
||||
{
|
||||
return $this->maxPageCount;
|
||||
}
|
||||
|
||||
public function getItemsPerPage() {
|
||||
public function getItemsPerPage()
|
||||
{
|
||||
return $this->itemsPerPage;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ use Gitea\Client;
|
||||
// Traits
|
||||
use Gitea\Core\Traits\RequestChainable;
|
||||
|
||||
// Interfaces
|
||||
use Gitea\Api\Interfaces\ApiRequesterInterface;
|
||||
use Gitea\Core\Interfaces\RequestChainableInterface;
|
||||
|
||||
@ -120,7 +121,8 @@ abstract class AbstractApiRequester implements ApiRequesterInterface, RequestCha
|
||||
*
|
||||
* @return Client
|
||||
*/
|
||||
public function getClient(): Client {
|
||||
public function getClient(): Client
|
||||
{
|
||||
return $this->client;
|
||||
}
|
||||
|
||||
@ -131,7 +133,8 @@ abstract class AbstractApiRequester implements ApiRequesterInterface, RequestCha
|
||||
* @param Client $client
|
||||
* @return self
|
||||
*/
|
||||
public function setClient(Client &$client) {
|
||||
public function setClient(Client &$client)
|
||||
{
|
||||
$this->client = $client;
|
||||
return $this;
|
||||
}
|
||||
@ -143,7 +146,8 @@ abstract class AbstractApiRequester implements ApiRequesterInterface, RequestCha
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthToken(): string {
|
||||
public function getAuthToken(): string
|
||||
{
|
||||
return $this->authToken;
|
||||
}
|
||||
|
||||
@ -154,7 +158,8 @@ abstract class AbstractApiRequester implements ApiRequesterInterface, RequestCha
|
||||
* @param string $authToken
|
||||
* @return self
|
||||
*/
|
||||
public function setAuthToken(string $authToken) {
|
||||
public function setAuthToken(string $authToken)
|
||||
{
|
||||
$this->authToken = $authToken;
|
||||
return $this;
|
||||
}
|
||||
@ -170,7 +175,8 @@ abstract class AbstractApiRequester implements ApiRequesterInterface, RequestCha
|
||||
* @param string $type The type of request ("all","get","post","put",etc.)
|
||||
* @return array
|
||||
*/
|
||||
public function getDefaultParametersForType($type = "all") {
|
||||
public function getDefaultParametersForType($type = "all")
|
||||
{
|
||||
if (!$type || $type == "all") {
|
||||
return $this->defaultParameters;
|
||||
} else {
|
||||
@ -194,7 +200,8 @@ abstract class AbstractApiRequester implements ApiRequesterInterface, RequestCha
|
||||
* @param string $type The type of request ("all", "get","post","put",etc.)
|
||||
* @return array
|
||||
*/
|
||||
public function getDefaultHeadersForType($type = "all") {
|
||||
public function getDefaultHeadersForType($type = "all")
|
||||
{
|
||||
if (!$type || $type == "all") {
|
||||
return $this->defaultHeaders;
|
||||
} else {
|
||||
|
||||
@ -59,5 +59,4 @@ class Branches extends AbstractApiRequester
|
||||
return $repositoryCollection;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ interface AllRequesterInterface
|
||||
*
|
||||
* @param integer $page The page of items to return
|
||||
* @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
|
||||
*/
|
||||
public function getPageOfAllItems(int $page = 1, int $limit = null, array $extraOptions = array());
|
||||
|
||||
@ -61,7 +61,7 @@ interface ApiRequesterInterface
|
||||
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 array $parameters
|
||||
@ -72,7 +72,7 @@ interface ApiRequesterInterface
|
||||
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 array $body
|
||||
@ -83,7 +83,7 @@ interface ApiRequesterInterface
|
||||
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 array $body
|
||||
@ -94,7 +94,7 @@ interface ApiRequesterInterface
|
||||
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 array $requestHeaders
|
||||
|
||||
@ -7,11 +7,11 @@ use GuzzleHttp\Psr7\Response;
|
||||
use Gitea\Client;
|
||||
use Gitea\Model\Organization;
|
||||
|
||||
use GuzzleHttp\Exception\ServerException;
|
||||
use Gitea\Api\Abstracts\AbstractApiRequester;
|
||||
|
||||
class Organizations extends AbstractApiRequester
|
||||
{
|
||||
|
||||
/**
|
||||
* Get an organization using its username and parse
|
||||
* it's information into an organization object
|
||||
@ -42,5 +42,4 @@ class Organizations extends AbstractApiRequester
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -23,7 +23,8 @@ class Repositories extends AbstractAllApiRequester
|
||||
* @param array $extraOptions An array of extra options to pass the API reoute
|
||||
* @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);
|
||||
}
|
||||
|
||||
@ -48,7 +49,7 @@ class Repositories extends AbstractAllApiRequester
|
||||
|
||||
$repositoryCollection = new ApiItemCollection();
|
||||
try {
|
||||
$response = $this->get("repos/search",[
|
||||
$response = $this->get("repos/search", [
|
||||
"page" => $page,
|
||||
"limit" => $limit
|
||||
]);
|
||||
@ -72,7 +73,6 @@ class Repositories extends AbstractAllApiRequester
|
||||
}
|
||||
}
|
||||
return $repositoryCollection;
|
||||
|
||||
} catch (ServerException $serverError) {
|
||||
return $repositoryCollection;
|
||||
}
|
||||
@ -105,7 +105,6 @@ class Repositories extends AbstractAllApiRequester
|
||||
);
|
||||
}
|
||||
return false;
|
||||
|
||||
} catch (ServerException $serverError) {
|
||||
return false;
|
||||
}
|
||||
@ -137,7 +136,6 @@ class Repositories extends AbstractAllApiRequester
|
||||
);
|
||||
}
|
||||
return false;
|
||||
|
||||
} catch (ServerException $serverError) {
|
||||
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)
|
||||
* @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();
|
||||
try {
|
||||
if ($ref !== "") {
|
||||
$response = $this->get("repos/$owner/$repoName/contents/$filepath",[
|
||||
$response = $this->get("repos/$owner/$repoName/contents/$filepath", [
|
||||
"ref" => $ref
|
||||
]);
|
||||
} else {
|
||||
@ -181,7 +179,6 @@ class Repositories extends AbstractAllApiRequester
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
} catch (ServerException $serverError) {
|
||||
return false;
|
||||
}
|
||||
@ -213,10 +210,8 @@ class Repositories extends AbstractAllApiRequester
|
||||
return $body;
|
||||
}
|
||||
return false;
|
||||
|
||||
} catch (ServerException $serverError) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -59,5 +59,4 @@ class Tags extends AbstractApiRequester
|
||||
return $repositoryCollection;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ class Client implements RequestChainableInterface
|
||||
/**
|
||||
* The secret for the push notifications system
|
||||
*
|
||||
* Used to varify incoming push notifications
|
||||
* Used to verify incoming push notifications
|
||||
* are from your Gitea server
|
||||
*
|
||||
* @var string
|
||||
@ -59,8 +59,8 @@ class Client implements RequestChainableInterface
|
||||
* @author Benjamin Blake (sitelease.ca)
|
||||
*
|
||||
* @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 $pushEventSecret The secret used to varify incoming push notifications
|
||||
* @param string|null $authToken A Gitea API auth token
|
||||
* @param string|null $pushEventSecret The secret used to verify incoming push notifications
|
||||
*/
|
||||
public function __construct($giteaURL, $authToken = null, $pushEventSecret = null)
|
||||
{
|
||||
@ -98,11 +98,13 @@ class Client implements RequestChainableInterface
|
||||
return $this->guzzleClient;
|
||||
}
|
||||
|
||||
public function getAuthToken() {
|
||||
public function getAuthToken()
|
||||
{
|
||||
return $this->authToken;
|
||||
}
|
||||
|
||||
public function setAuthToken($value) {
|
||||
public function setAuthToken($value)
|
||||
{
|
||||
$this->authToken = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -133,7 +135,7 @@ class Client implements RequestChainableInterface
|
||||
* @param string $needle
|
||||
* @return boolean
|
||||
*/
|
||||
function endsWith($haystack, $needle)
|
||||
public function endsWith($haystack, $needle)
|
||||
{
|
||||
return substr($haystack, -strlen($needle))===$needle;
|
||||
}
|
||||
@ -147,7 +149,8 @@ class Client implements RequestChainableInterface
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function checkAuthToken($softErrors = false) {
|
||||
public function checkAuthToken($softErrors = false)
|
||||
{
|
||||
$authToken = $this->authToken;
|
||||
if (!$authToken) {
|
||||
if ($softErrors) {
|
||||
@ -217,5 +220,4 @@ class Client implements RequestChainableInterface
|
||||
{
|
||||
return new Organizations($this, $this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,25 +4,26 @@ namespace Gitea\Collections;
|
||||
|
||||
use Gitea\Collections\Interfaces\ApiCollectionInterface;
|
||||
|
||||
use \Countable;
|
||||
use \IteratorAggregate;
|
||||
use \ArrayIterator;
|
||||
use Countable;
|
||||
use IteratorAggregate;
|
||||
use ArrayIterator;
|
||||
|
||||
class ApiItemCollection implements ApiCollectionInterface, IteratorAggregate, Countable
|
||||
{
|
||||
private $items = array();
|
||||
|
||||
public function __construct($internalArray = array()) {
|
||||
public function __construct($internalArray = array())
|
||||
{
|
||||
if ($internalArray && is_array($internalArray)) {
|
||||
$this->items = $internalArray;
|
||||
}
|
||||
}
|
||||
|
||||
public function addItem($apiObject, $key = null) {
|
||||
public function addItem($apiObject, $key = null)
|
||||
{
|
||||
if ($key == null) {
|
||||
$this->items[] = $apiObject;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (isset($this->items[$key])) {
|
||||
return false;
|
||||
} else {
|
||||
@ -31,7 +32,8 @@ class ApiItemCollection implements ApiCollectionInterface, IteratorAggregate, Co
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteItem($key) {
|
||||
public function deleteItem($key)
|
||||
{
|
||||
if (isset($this->items[$key])) {
|
||||
unset($this->items[$key]);
|
||||
} else {
|
||||
@ -39,31 +41,37 @@ class ApiItemCollection implements ApiCollectionInterface, IteratorAggregate, Co
|
||||
}
|
||||
}
|
||||
|
||||
public function getItem($key) {
|
||||
public function getItem($key)
|
||||
{
|
||||
if (isset($this->items[$key])) {
|
||||
return $this->items[$key];
|
||||
} else {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function keys() {
|
||||
public function keys()
|
||||
{
|
||||
return array_keys($this->items);
|
||||
}
|
||||
|
||||
public function count() {
|
||||
public function count()
|
||||
{
|
||||
return count($this->items);
|
||||
}
|
||||
|
||||
public function keyExists($key) {
|
||||
public function keyExists($key)
|
||||
{
|
||||
return isset($this->items[$key]);
|
||||
}
|
||||
|
||||
public function toArray() {
|
||||
public function toArray()
|
||||
{
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
public function getIterator() {
|
||||
public function getIterator()
|
||||
{
|
||||
return new ArrayIterator($this->items);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ use Gitea\Client;
|
||||
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)
|
||||
*/
|
||||
@ -31,7 +31,7 @@ interface RequestChainableInterface
|
||||
public function setCaller(?object $object);
|
||||
|
||||
/**
|
||||
* Return the request chain heirarchy
|
||||
* Return the request chain hierarchy
|
||||
* as an array of objects
|
||||
*
|
||||
* This is useful if you need to know
|
||||
@ -58,11 +58,11 @@ interface RequestChainableInterface
|
||||
public function searchRequestChain(string $class): ?object;
|
||||
|
||||
/**
|
||||
* Return the request chain heirarchy
|
||||
* Return the request chain hierarchy
|
||||
* as a string of class names
|
||||
*
|
||||
* 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)
|
||||
* @return array
|
||||
|
||||
@ -17,7 +17,7 @@ trait RequestChainable
|
||||
/**
|
||||
* The object that called this object
|
||||
*
|
||||
* @var string
|
||||
* @var object
|
||||
*/
|
||||
private $caller;
|
||||
|
||||
@ -47,7 +47,7 @@ trait RequestChainable
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the request chain heirarchy
|
||||
* Return the request chain hierarchy
|
||||
* as an array of objects
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* 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)
|
||||
* @return array
|
||||
@ -151,5 +151,4 @@ trait RequestChainable
|
||||
|
||||
return $repository;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5,8 +5,8 @@ namespace Gitea\Model\Abstracts;
|
||||
use Gitea\Client;
|
||||
use Gitea\Api\Interfaces\ApiRequesterInterface;
|
||||
|
||||
use \stdClass;
|
||||
use \JsonSerializable;
|
||||
use stdClass;
|
||||
use JsonSerializable;
|
||||
|
||||
// Traits
|
||||
use Gitea\Core\Traits\RequestChainable;
|
||||
@ -16,7 +16,6 @@ use Gitea\Core\Interfaces\RequestChainableInterface;
|
||||
|
||||
abstract class AbstractApiModel implements ApiModelInterface, JsonSerializable, RequestChainableInterface
|
||||
{
|
||||
|
||||
use RequestChainable;
|
||||
|
||||
/**
|
||||
@ -28,7 +27,8 @@ abstract class AbstractApiModel implements ApiModelInterface, JsonSerializable,
|
||||
* @param object|null $caller The object that called this method
|
||||
* @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->setCaller($caller);
|
||||
}
|
||||
@ -59,7 +59,8 @@ abstract class AbstractApiModel implements ApiModelInterface, JsonSerializable,
|
||||
* @param object|null $caller The object that called this method
|
||||
* @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");
|
||||
return false;
|
||||
}
|
||||
@ -72,7 +73,8 @@ abstract class AbstractApiModel implements ApiModelInterface, JsonSerializable,
|
||||
*
|
||||
* @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");
|
||||
return self;
|
||||
}
|
||||
@ -84,7 +86,8 @@ abstract class AbstractApiModel implements ApiModelInterface, JsonSerializable,
|
||||
*
|
||||
* @return Client
|
||||
*/
|
||||
public function getClient(): Client {
|
||||
public function getClient(): Client
|
||||
{
|
||||
return $this->client;
|
||||
}
|
||||
|
||||
@ -95,7 +98,8 @@ abstract class AbstractApiModel implements ApiModelInterface, JsonSerializable,
|
||||
* @param Client $client
|
||||
* @return self
|
||||
*/
|
||||
public function setClient(Client &$client) {
|
||||
public function setClient(Client &$client)
|
||||
{
|
||||
$this->client = $client;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -8,13 +8,14 @@ use Psr\Http\Message\UriInterface;
|
||||
use Gitea\Client;
|
||||
use Gitea\Model\PayloadCommit;
|
||||
|
||||
use \InvalidArgumentException;
|
||||
use InvalidArgumentException;
|
||||
use stdClass;
|
||||
|
||||
use Gitea\Model\Abstracts\AbstractApiModel;
|
||||
|
||||
/** Represents a Gitea branch. */
|
||||
class Branch extends AbstractApiModel {
|
||||
|
||||
class Branch extends AbstractApiModel
|
||||
{
|
||||
/** @var string The branch's name */
|
||||
private $name = '';
|
||||
|
||||
@ -25,7 +26,7 @@ class Branch extends AbstractApiModel {
|
||||
private $protected = true;
|
||||
|
||||
/** @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 */
|
||||
private $userCanMerge = false;
|
||||
@ -37,7 +38,8 @@ class Branch extends AbstractApiModel {
|
||||
* @param object|null $caller The object that called this method
|
||||
* @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);
|
||||
if (count($args) >= 1) {
|
||||
$name = $args[0];
|
||||
@ -59,7 +61,8 @@ class Branch extends AbstractApiModel {
|
||||
* @param object $map A JSON map representing an branch.
|
||||
* @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(
|
||||
$client,
|
||||
@ -75,9 +78,10 @@ class Branch extends AbstractApiModel {
|
||||
|
||||
/**
|
||||
* 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) [
|
||||
'name' => $this->getName(),
|
||||
'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;
|
||||
}
|
||||
|
||||
public function setName(string $name): self {
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCommit(): ?PayloadCommit {
|
||||
public function getCommit(): ?PayloadCommit
|
||||
{
|
||||
return $this->commit;
|
||||
}
|
||||
|
||||
public function setCommit(?PayloadCommit $object): self {
|
||||
public function setCommit(?PayloadCommit $object): self
|
||||
{
|
||||
$this->commit = $object;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getProtected() {
|
||||
public function getProtected(): bool
|
||||
{
|
||||
return $this->protected;
|
||||
}
|
||||
|
||||
public function setProtected(bool $boolean): self {
|
||||
public function setProtected(bool $boolean): self
|
||||
{
|
||||
$this->protected = $boolean;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCanUserPush() {
|
||||
public function getCanUserPush(): bool
|
||||
{
|
||||
return $this->canUserPush;
|
||||
}
|
||||
|
||||
public function setCanUserPush(bool $boolean): self {
|
||||
public function setCanUserPush(bool $boolean): self
|
||||
{
|
||||
$this->canUserPush = $boolean;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUserCanMerge() {
|
||||
public function getUserCanMerge(): bool
|
||||
{
|
||||
return $this->userCanMerge;
|
||||
}
|
||||
|
||||
public function setUserCanMerge(bool $boolean): self {
|
||||
public function setUserCanMerge(bool $boolean): self
|
||||
{
|
||||
$this->userCanMerge = $boolean;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5,11 +5,10 @@ namespace Gitea\Model\Interfaces;
|
||||
use Gitea\Client;
|
||||
use Gitea\Api\Interfaces\ApiRequesterInterface;
|
||||
|
||||
use \stdClass;
|
||||
use stdClass;
|
||||
|
||||
interface ApiModelInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Creates a new API model object
|
||||
*
|
||||
@ -39,7 +38,7 @@ interface ApiModelInterface
|
||||
* @param object|null $caller The object that called this method
|
||||
* @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.
|
||||
@ -51,7 +50,7 @@ interface ApiModelInterface
|
||||
*
|
||||
* @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)
|
||||
@ -70,5 +69,4 @@ interface ApiModelInterface
|
||||
* @return self
|
||||
*/
|
||||
public function setClient(Client &$client);
|
||||
|
||||
}
|
||||
|
||||
@ -7,13 +7,14 @@ use Psr\Http\Message\UriInterface;
|
||||
|
||||
use Gitea\Client;
|
||||
|
||||
use \InvalidArgumentException;
|
||||
use stdClass;
|
||||
use InvalidArgumentException;
|
||||
|
||||
use Gitea\Model\Abstracts\AbstractApiModel;
|
||||
|
||||
/** Represents a Gitea organization. */
|
||||
class Organization extends AbstractApiModel {
|
||||
|
||||
class Organization extends AbstractApiModel
|
||||
{
|
||||
/** @var UriInterface|null A URL pointing to the organization's avatar. */
|
||||
private $avatarURL = '';
|
||||
|
||||
@ -45,7 +46,8 @@ class Organization extends AbstractApiModel {
|
||||
* @param string $username The organization name.
|
||||
* @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);
|
||||
if (count($args) >= 2) {
|
||||
$username = $args[0];
|
||||
@ -73,7 +75,8 @@ class Organization extends AbstractApiModel {
|
||||
* @param object $map A JSON map representing an organization.
|
||||
* @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(
|
||||
$client,
|
||||
@ -91,9 +94,10 @@ class Organization extends AbstractApiModel {
|
||||
|
||||
/**
|
||||
* 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) [
|
||||
'avatar_url' => ($url = $this->getAvatarURL()) ? (string) $url : null,
|
||||
'description' => $this->getDescription(),
|
||||
@ -110,71 +114,85 @@ class Organization extends AbstractApiModel {
|
||||
* Gets the organization identifier.
|
||||
* @return int The organization identifier.
|
||||
*/
|
||||
function getId(): int {
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getAvatarURL(): ?UriInterface {
|
||||
public function getAvatarURL(): ?UriInterface
|
||||
{
|
||||
return $this->avatarURL;
|
||||
}
|
||||
|
||||
public function setAvatarURL(?UriInterface $value): self {
|
||||
public function setAvatarURL(?UriInterface $value): self
|
||||
{
|
||||
$this->avatarURL = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription(string $value): self {
|
||||
public function setDescription(string $value): self
|
||||
{
|
||||
$this->description = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFullName() {
|
||||
public function getFullName()
|
||||
{
|
||||
return $this->fullName;
|
||||
}
|
||||
|
||||
public function setFullName(string $value): self {
|
||||
public function setFullName(string $value): self
|
||||
{
|
||||
$this->fullName = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLocation() {
|
||||
public function getLocation()
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
public function setLocation(string $value): self {
|
||||
public function setLocation(string $value): self
|
||||
{
|
||||
$this->location = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUsername() {
|
||||
public function getUsername()
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
public function setUsername(string $value): self {
|
||||
public function setUsername(string $value): self
|
||||
{
|
||||
$this->username = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getVisibility() {
|
||||
public function getVisibility()
|
||||
{
|
||||
return $this->visibility;
|
||||
}
|
||||
|
||||
public function setVisibility(string $value): self {
|
||||
public function setVisibility(string $value): self
|
||||
{
|
||||
$this->visibility = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getWebsite(): ?UriInterface {
|
||||
public function getWebsite(): ?UriInterface
|
||||
{
|
||||
return $this->website;
|
||||
}
|
||||
|
||||
public function setWebsite(?UriInterface $value): self {
|
||||
public function setWebsite(?UriInterface $value): self
|
||||
{
|
||||
$this->website = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,16 +2,18 @@
|
||||
|
||||
namespace Gitea\Model;
|
||||
|
||||
use Gitea\Client;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
||||
use Gitea\Client;
|
||||
use stdClass;
|
||||
use InvalidArgumentException;
|
||||
|
||||
use Gitea\Model\Abstracts\AbstractApiModel;
|
||||
|
||||
/** Represents a Gitea owner. */
|
||||
class Owner extends AbstractApiModel {
|
||||
|
||||
class Owner extends AbstractApiModel
|
||||
{
|
||||
/** @var int The owner identifier. */
|
||||
private $id;
|
||||
|
||||
@ -43,7 +45,8 @@ class Owner extends AbstractApiModel {
|
||||
* @param int $id The owner identifier.
|
||||
* @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);
|
||||
if (count($args) >= 2) {
|
||||
$id = $args[0];
|
||||
@ -71,7 +74,8 @@ class Owner extends AbstractApiModel {
|
||||
* @param object $map A JSON map representing a owner.
|
||||
* @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(
|
||||
$client,
|
||||
@ -90,9 +94,10 @@ class Owner extends AbstractApiModel {
|
||||
|
||||
/**
|
||||
* 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) [
|
||||
'id' => $this->getId(),
|
||||
'login' => $this->getLogin(),
|
||||
@ -109,7 +114,8 @@ class Owner extends AbstractApiModel {
|
||||
* Gets the owner identifier.
|
||||
* @return int The owner identifier.
|
||||
*/
|
||||
function getId(): int {
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
@ -117,7 +123,8 @@ class Owner extends AbstractApiModel {
|
||||
* Gets the name of the Gitea account.
|
||||
* @return string The name of the Gitea account.
|
||||
*/
|
||||
function getLogin(): string {
|
||||
public function getLogin(): string
|
||||
{
|
||||
return $this->login;
|
||||
}
|
||||
|
||||
@ -126,7 +133,8 @@ class Owner extends AbstractApiModel {
|
||||
* @param string $value The new Gitea account.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setLogin(string $value): self {
|
||||
public function setLogin(string $value): self
|
||||
{
|
||||
$this->login = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -135,7 +143,8 @@ class Owner extends AbstractApiModel {
|
||||
* Gets the full name.
|
||||
* @return string The full name.
|
||||
*/
|
||||
function getFullName(): string {
|
||||
public function getFullName(): string
|
||||
{
|
||||
return $this->fullName;
|
||||
}
|
||||
|
||||
@ -144,7 +153,8 @@ class Owner extends AbstractApiModel {
|
||||
* @param string $value The new full name.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setFullName(string $value): self {
|
||||
public function setFullName(string $value): self
|
||||
{
|
||||
$this->fullName = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -153,7 +163,8 @@ class Owner extends AbstractApiModel {
|
||||
* Gets the mail address.
|
||||
* @return string The mail address.
|
||||
*/
|
||||
function getEmail(): string {
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
@ -162,7 +173,8 @@ class Owner extends AbstractApiModel {
|
||||
* @param string $value The new mail address.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setEmail(string $value): self {
|
||||
public function setEmail(string $value): self
|
||||
{
|
||||
$this->email = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -171,7 +183,8 @@ class Owner extends AbstractApiModel {
|
||||
* Gets 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;
|
||||
}
|
||||
|
||||
@ -180,7 +193,8 @@ class Owner extends AbstractApiModel {
|
||||
* @param UriInterface|null $value The new avatar URL.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setAvatarUrl(?UriInterface $value): self {
|
||||
public function setAvatarUrl(?UriInterface $value): self
|
||||
{
|
||||
$this->avatarUrl = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -189,7 +203,8 @@ class Owner extends AbstractApiModel {
|
||||
* Gets the owner locale.
|
||||
* @return string The owner locale.
|
||||
*/
|
||||
function getLanguage(): string {
|
||||
public function getLanguage(): string
|
||||
{
|
||||
return $this->language;
|
||||
}
|
||||
|
||||
@ -198,27 +213,31 @@ class Owner extends AbstractApiModel {
|
||||
* @param string $value The new owner locale.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setLanguage(string $value): self {
|
||||
public function setLanguage(string $value): self
|
||||
{
|
||||
$this->language = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIsAdmin(): bool {
|
||||
public function getIsAdmin(): bool
|
||||
{
|
||||
return $this->isAdmin;
|
||||
}
|
||||
|
||||
public function setIsAdmin($boolean): self {
|
||||
public function setIsAdmin($boolean): self
|
||||
{
|
||||
$this->isAdmin = $boolean;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUsername(): string {
|
||||
public function getUsername(): string
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
public function setUsername($string): self {
|
||||
public function setUsername($string): self
|
||||
{
|
||||
$this->username = $string;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -9,13 +9,15 @@ use Gitea\Client;
|
||||
use Gitea\Model\PayloadUser;
|
||||
use Gitea\Model\PayloadCommitVerification;
|
||||
|
||||
use \InvalidArgumentException;
|
||||
use stdClass;
|
||||
use DateTime;
|
||||
use InvalidArgumentException;
|
||||
|
||||
use Gitea\Model\Abstracts\AbstractApiModel;
|
||||
|
||||
/** Represents a commit. */
|
||||
class PayloadCommit extends AbstractApiModel {
|
||||
|
||||
class PayloadCommit extends AbstractApiModel
|
||||
{
|
||||
/** @var PayloadUser|null The person who authored the commit. */
|
||||
private $author;
|
||||
|
||||
@ -28,7 +30,7 @@ class PayloadCommit extends AbstractApiModel {
|
||||
/** @var string The commit message. */
|
||||
private $message;
|
||||
|
||||
/** @var \DateTime|null The commit date. */
|
||||
/** @var DateTime|null The commit date. */
|
||||
private $timestamp;
|
||||
|
||||
/** @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 $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);
|
||||
if (count($args) >= 2) {
|
||||
$id = $args[0];
|
||||
@ -72,7 +75,8 @@ class PayloadCommit extends AbstractApiModel {
|
||||
* @param object $map A JSON map representing a commit.
|
||||
* @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(
|
||||
$client,
|
||||
@ -83,7 +87,7 @@ class PayloadCommit extends AbstractApiModel {
|
||||
)
|
||||
->setAuthor(isset($map->author) && is_object($map->author) ? PayloadUser::fromJson($client, null, $map->author) : null)
|
||||
->setCommitter(isset($map->committer) && is_object($map->committer) ? PayloadUser::fromJson($client, null, $map->committer) : null)
|
||||
->setTimestamp(isset($map->timestamp) && is_string($map->timestamp) ? new \DateTime($map->timestamp) : null)
|
||||
->setTimestamp(isset($map->timestamp) && is_string($map->timestamp) ? new DateTime($map->timestamp) : null)
|
||||
->setUrl(isset($map->url) && is_string($map->url) ? new Uri($map->url) : null)
|
||||
->setVerification(isset($map->verification) && is_object($map->verification) ? PayloadCommitVerification::fromJson($client, null, $map->verification) : null);
|
||||
}
|
||||
@ -92,7 +96,8 @@ class PayloadCommit extends AbstractApiModel {
|
||||
* Gets 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;
|
||||
}
|
||||
|
||||
@ -100,7 +105,8 @@ class PayloadCommit extends AbstractApiModel {
|
||||
* Gets 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;
|
||||
}
|
||||
|
||||
@ -108,7 +114,8 @@ class PayloadCommit extends AbstractApiModel {
|
||||
* Gets the commit hash.
|
||||
* @return string The commit hash.
|
||||
*/
|
||||
function getId(): string {
|
||||
public function getId(): string
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
@ -116,15 +123,17 @@ class PayloadCommit extends AbstractApiModel {
|
||||
* Gets the commit message.
|
||||
* @return string The commit message.
|
||||
*/
|
||||
function getMessage(): string {
|
||||
public function getMessage(): string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
@ -132,7 +141,8 @@ class PayloadCommit extends AbstractApiModel {
|
||||
* Gets 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;
|
||||
}
|
||||
|
||||
@ -140,15 +150,17 @@ class PayloadCommit extends AbstractApiModel {
|
||||
* Gets 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) [
|
||||
'author' => ($author = $this->getAuthor()) ? $author->jsonSerialize() : null,
|
||||
'committer' => ($committer = $this->getCommitter()) ? $committer->jsonSerialize() : null,
|
||||
@ -165,7 +177,8 @@ class PayloadCommit extends AbstractApiModel {
|
||||
* @param PayloadUser|null $value The new author.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setAuthor(?PayloadUser $value): self {
|
||||
public function setAuthor(?PayloadUser $value): self
|
||||
{
|
||||
$this->author = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -175,7 +188,8 @@ class PayloadCommit extends AbstractApiModel {
|
||||
* @param PayloadUser|null $value The new committer.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setCommitter(?PayloadUser $value): self {
|
||||
public function setCommitter(?PayloadUser $value): self
|
||||
{
|
||||
$this->committer = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -185,17 +199,19 @@ class PayloadCommit extends AbstractApiModel {
|
||||
* @param string $value The new message.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setMessage(string $value): self {
|
||||
public function setMessage(string $value): self
|
||||
{
|
||||
$this->message = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the commit date.
|
||||
* @param \DateTime|null $value The new commit date.
|
||||
* @param DateTime|null $value The new commit date.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setTimestamp(?\DateTime $value): self {
|
||||
public function setTimestamp(?DateTime $value): self
|
||||
{
|
||||
$this->timestamp = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -205,7 +221,8 @@ class PayloadCommit extends AbstractApiModel {
|
||||
* @param UriInterface|null $value The new commit URL.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setUrl(?UriInterface $value): self {
|
||||
public function setUrl(?UriInterface $value): self
|
||||
{
|
||||
$this->url = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -215,7 +232,8 @@ class PayloadCommit extends AbstractApiModel {
|
||||
* @param PayloadCommitVerification|null $value The new message.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setVerification(?PayloadCommitVerification $value): self {
|
||||
public function setVerification(?PayloadCommitVerification $value): self
|
||||
{
|
||||
$this->verification = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -7,13 +7,14 @@ use Psr\Http\Message\UriInterface;
|
||||
|
||||
use Gitea\Client;
|
||||
|
||||
use \InvalidArgumentException;
|
||||
use stdClass;
|
||||
use InvalidArgumentException;
|
||||
|
||||
use Gitea\Model\Abstracts\AbstractApiModel;
|
||||
|
||||
/** Represents the GPG verification of a commit. */
|
||||
class PayloadCommitVerification extends AbstractApiModel {
|
||||
|
||||
class PayloadCommitVerification extends AbstractApiModel
|
||||
{
|
||||
/** @var bool Value indicating whether the verification has succeeded. */
|
||||
private $isVerified;
|
||||
|
||||
@ -32,7 +33,8 @@ class PayloadCommitVerification extends AbstractApiModel {
|
||||
* @param object|null $caller The object that called this method
|
||||
* @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);
|
||||
if (count($args) >= 1) {
|
||||
$isVerified = $args[0];
|
||||
@ -54,7 +56,8 @@ class PayloadCommitVerification extends AbstractApiModel {
|
||||
* @param object $map A JSON map representing a commit.
|
||||
* @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(
|
||||
$client,
|
||||
@ -71,7 +74,8 @@ class PayloadCommitVerification extends AbstractApiModel {
|
||||
* Gets 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;
|
||||
}
|
||||
|
||||
@ -79,7 +83,8 @@ class PayloadCommitVerification extends AbstractApiModel {
|
||||
* Gets 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;
|
||||
}
|
||||
|
||||
@ -87,7 +92,8 @@ class PayloadCommitVerification extends AbstractApiModel {
|
||||
* Gets 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;
|
||||
}
|
||||
|
||||
@ -95,15 +101,17 @@ class PayloadCommitVerification extends AbstractApiModel {
|
||||
* Gets a value indicating whether the verification has succeeded.
|
||||
* @return bool `true` if the verification has succeeded, otherwise `false`.
|
||||
*/
|
||||
function isVerified(): bool {
|
||||
public function isVerified(): bool
|
||||
{
|
||||
return $this->isVerified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this object to a map in JSON format.
|
||||
* @return \stdClass The map in JSON format corresponding to this object.
|
||||
* @return stdClass The map in JSON format corresponding to this object.
|
||||
*/
|
||||
function jsonSerialize(): \stdClass {
|
||||
public function jsonSerialize(): stdClass
|
||||
{
|
||||
return (object) [
|
||||
'payload' => $this->getPayload(),
|
||||
'reason' => $this->getReason(),
|
||||
@ -117,7 +125,8 @@ class PayloadCommitVerification extends AbstractApiModel {
|
||||
* @param string $value A new custom message.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setPayload(string $value): self {
|
||||
public function setPayload(string $value): self
|
||||
{
|
||||
$this->payload = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -127,7 +136,8 @@ class PayloadCommitVerification extends AbstractApiModel {
|
||||
* @param string $value A new message providing details about the verification.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setReason(string $value): self {
|
||||
public function setReason(string $value): self
|
||||
{
|
||||
$this->reason = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -137,7 +147,8 @@ class PayloadCommitVerification extends AbstractApiModel {
|
||||
* @param string $value The new signing key.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setSignature(string $value): self {
|
||||
public function setSignature(string $value): self
|
||||
{
|
||||
$this->signature = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -147,7 +158,8 @@ class PayloadCommitVerification extends AbstractApiModel {
|
||||
* @param bool $value `true` if the verification has succeeded, otherwise `false`.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setVerified(bool $value): self {
|
||||
public function setVerified(bool $value): self
|
||||
{
|
||||
$this->isVerified = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -7,14 +7,14 @@ use Psr\Http\Message\UriInterface;
|
||||
|
||||
use Gitea\Client;
|
||||
|
||||
use \stdClass;
|
||||
use \InvalidArgumentException;
|
||||
use stdClass;
|
||||
use InvalidArgumentException;
|
||||
|
||||
use Gitea\Model\Abstracts\AbstractApiModel;
|
||||
|
||||
/** Represents the author or committer of a commit. */
|
||||
class PayloadUser extends AbstractApiModel {
|
||||
|
||||
class PayloadUser extends AbstractApiModel
|
||||
{
|
||||
/** @var string The mail address. */
|
||||
private $email = '';
|
||||
|
||||
@ -30,7 +30,8 @@ class PayloadUser extends AbstractApiModel {
|
||||
* @param object|null $caller The object that called this method
|
||||
* @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);
|
||||
if (count($args) >= 1) {
|
||||
$username = $args[0];
|
||||
@ -52,7 +53,8 @@ class PayloadUser extends AbstractApiModel {
|
||||
* @param object $map A JSON map representing a user.
|
||||
* @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(
|
||||
$client,
|
||||
@ -68,7 +70,8 @@ class PayloadUser extends AbstractApiModel {
|
||||
* Gets the mail address.
|
||||
* @return string The mail address.
|
||||
*/
|
||||
function getEmail(): string {
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
@ -76,7 +79,8 @@ class PayloadUser extends AbstractApiModel {
|
||||
* Gets the full name.
|
||||
* @return string The full name.
|
||||
*/
|
||||
function getName(): string {
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
@ -84,7 +88,8 @@ class PayloadUser extends AbstractApiModel {
|
||||
* Gets the name of the Gitea account.
|
||||
* @return string The name of the Gitea account.
|
||||
*/
|
||||
function getUsername(): string {
|
||||
public function getUsername(): string
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
@ -92,7 +97,8 @@ class PayloadUser extends AbstractApiModel {
|
||||
* Converts this object to a map in JSON format.
|
||||
* @return stdClass The map in JSON format corresponding to this object.
|
||||
*/
|
||||
function jsonSerialize(): \stdClass {
|
||||
public function jsonSerialize(): stdClass
|
||||
{
|
||||
return (object) [
|
||||
'email' => $this->getEmail(),
|
||||
'name' => $this->getName(),
|
||||
@ -105,7 +111,8 @@ class PayloadUser extends AbstractApiModel {
|
||||
* @param string $value The new mail address.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setEmail(string $value): self {
|
||||
public function setEmail(string $value): self
|
||||
{
|
||||
$this->email = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -115,7 +122,8 @@ class PayloadUser extends AbstractApiModel {
|
||||
* @param string $value The new full name.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setName(string $value): self {
|
||||
public function setName(string $value): self
|
||||
{
|
||||
$this->name = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -7,13 +7,14 @@ use Psr\Http\Message\UriInterface;
|
||||
|
||||
use Gitea\Client;
|
||||
|
||||
use \InvalidArgumentException;
|
||||
use stdClass;
|
||||
use InvalidArgumentException;
|
||||
|
||||
use Gitea\Model\Abstracts\AbstractApiModel;
|
||||
|
||||
/** Represents a set of permissions. */
|
||||
class Permission extends AbstractApiModel {
|
||||
|
||||
class Permission extends AbstractApiModel
|
||||
{
|
||||
/** @var bool Value indicating whether administrator access is allowed. */
|
||||
private $admin;
|
||||
|
||||
@ -31,7 +32,8 @@ class Permission extends AbstractApiModel {
|
||||
* @param bool $pull Value indicating whether pull 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);
|
||||
if (count($args) >= 2) {
|
||||
$admin = $args[0];
|
||||
@ -63,7 +65,8 @@ class Permission extends AbstractApiModel {
|
||||
* @param object $map A JSON map representing a user.
|
||||
* @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(
|
||||
$client,
|
||||
$caller,
|
||||
@ -77,7 +80,8 @@ class Permission extends AbstractApiModel {
|
||||
* Gets a value indicating whether administrator access is allowed.
|
||||
* @return bool `true` if administrator access is allowed, otherwise `false`.
|
||||
*/
|
||||
function getAdmin(): bool {
|
||||
public function getAdmin(): bool
|
||||
{
|
||||
return $this->admin;
|
||||
}
|
||||
|
||||
@ -85,7 +89,8 @@ class Permission extends AbstractApiModel {
|
||||
* Gets a value indicating whether pull is allowed.
|
||||
* @return bool `true` if pull is allowed, otherwise `false`.
|
||||
*/
|
||||
function getPull(): bool {
|
||||
public function getPull(): bool
|
||||
{
|
||||
return $this->pull;
|
||||
}
|
||||
|
||||
@ -93,15 +98,17 @@ class Permission extends AbstractApiModel {
|
||||
* Gets a value indicating whether push is allowed.
|
||||
* @return bool `true` if push is allowed, otherwise `false`.
|
||||
*/
|
||||
function getPush(): bool {
|
||||
public function getPush(): bool
|
||||
{
|
||||
return $this->push;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this object to a map in JSON format.
|
||||
* @return \stdClass The map in JSON format corresponding to this object.
|
||||
* @return stdClass The map in JSON format corresponding to this object.
|
||||
*/
|
||||
function jsonSerialize(): \stdClass {
|
||||
public function jsonSerialize(): stdClass
|
||||
{
|
||||
return (object) [
|
||||
'admin' => $this->getAdmin(),
|
||||
'pull' => $this->getPull(),
|
||||
@ -114,7 +121,8 @@ class Permission extends AbstractApiModel {
|
||||
* @param bool $value `true` to allow administrator access, otherwise `false`.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setAdmin(bool $value): self {
|
||||
public function setAdmin(bool $value): self
|
||||
{
|
||||
$this->admin = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -124,7 +132,8 @@ class Permission extends AbstractApiModel {
|
||||
* @param bool $value `true` to allow pull, otherwise `false`.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setPull(bool $value): self {
|
||||
public function setPull(bool $value): self
|
||||
{
|
||||
$this->pull = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -134,7 +143,8 @@ class Permission extends AbstractApiModel {
|
||||
* @param bool $value `true` to allow push, otherwise `false`.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setPush(bool $value): self {
|
||||
public function setPush(bool $value): self
|
||||
{
|
||||
$this->push = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Gitea\Model;
|
||||
|
||||
@ -12,17 +13,19 @@ use Gitea\Api\Repositories;
|
||||
use Gitea\Api\Branches;
|
||||
use Gitea\Api\Tags;
|
||||
|
||||
use \InvalidArgumentException;
|
||||
use stdClass;
|
||||
use DateTime;
|
||||
use InvalidArgumentException;
|
||||
|
||||
use Gitea\Model\Abstracts\AbstractApiModel;
|
||||
|
||||
/** Represents a repository. */
|
||||
class Repository extends AbstractApiModel {
|
||||
|
||||
class Repository extends AbstractApiModel
|
||||
{
|
||||
/** @var UriInterface|null The HTTP-based URL for cloning this repository. */
|
||||
private $cloneUrl;
|
||||
|
||||
/** @var \DateTime|null The date the repository was created. */
|
||||
/** @var DateTime|null The date the repository was created. */
|
||||
private $createdAt;
|
||||
|
||||
/** @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. */
|
||||
private $starsCount = 0;
|
||||
|
||||
/** @var \DateTime|null The date the repository was updated. */
|
||||
/** @var DateTime|null The date the repository was updated. */
|
||||
private $updatedAt;
|
||||
|
||||
/** @var int The number of watchers of this repository. */
|
||||
@ -95,24 +98,34 @@ class Repository extends AbstractApiModel {
|
||||
* @param int $id The repository identifier.
|
||||
* @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);
|
||||
if (count($args) >= 2) {
|
||||
$id = $args[0];
|
||||
$fullName = $args[1];
|
||||
if (!is_numeric($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)) {
|
||||
$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->setFullName($fullName);
|
||||
} else {
|
||||
$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.
|
||||
* @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(
|
||||
$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)
|
||||
->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 : '')
|
||||
->setDescription(isset($map->description) && is_string($map->description) ? $map->description : '')
|
||||
->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)
|
||||
->setMirror(isset($map->mirror) && is_bool($map->mirror) ? $map->mirror : false)
|
||||
->setName(isset($map->name) && is_string($map->name) ? $map->name : '')
|
||||
->setOpenIssuesCount(isset($map->open_issues_count) && is_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)
|
||||
->setParent(isset($map->parent) && is_object($map->parent) ? Repository::fromJson($client, null, $map->parent) : null)
|
||||
->setPermissions(isset($map->permissions) && is_object($map->permissions) ? Permission::fromJson($client, null, $map->permissions) : null)
|
||||
->setParent(
|
||||
isset($map->parent)
|
||||
&& is_object($map->parent)
|
||||
? Repository::fromJson($client, null, $map->parent) : null
|
||||
)
|
||||
->setPermissions(
|
||||
isset($map->permissions)
|
||||
&& is_object($map->permissions)
|
||||
? Permission::fromJson($client, null, $map->permissions) : null
|
||||
)
|
||||
->setPrivate(isset($map->private) && is_bool($map->private) ? $map->private : false)
|
||||
->setSize(isset($map->size) && is_numeric($map->size) ? $map->size : 0)
|
||||
->setSshUrl(isset($map->ssh_url) && is_string($map->ssh_url) ? new Uri($map->ssh_url) : null)
|
||||
->setStarsCount(isset($map->stars_count) && is_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)
|
||||
->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.
|
||||
* @return UriInterface|null The HTTP-based URL for cloning this repository.
|
||||
*/
|
||||
function getCloneUrl(): ?UriInterface {
|
||||
public function getCloneUrl(): ?UriInterface
|
||||
{
|
||||
return $this->cloneUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
@ -175,7 +203,8 @@ class Repository extends AbstractApiModel {
|
||||
* Gets the name of the default branch.
|
||||
* @return string The name of the default branch.
|
||||
*/
|
||||
function getDefaultBranch(): string {
|
||||
public function getDefaultBranch(): string
|
||||
{
|
||||
return $this->defaultBranch;
|
||||
}
|
||||
|
||||
@ -183,7 +212,8 @@ class Repository extends AbstractApiModel {
|
||||
* Gets the repository description.
|
||||
* @return string The repository description.
|
||||
*/
|
||||
function getDescription(): string {
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
@ -191,7 +221,8 @@ class Repository extends AbstractApiModel {
|
||||
* Gets 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;
|
||||
}
|
||||
|
||||
@ -199,7 +230,8 @@ class Repository extends AbstractApiModel {
|
||||
* Gets the full name.
|
||||
* @return string The full name.
|
||||
*/
|
||||
function getFullName(): string {
|
||||
public function getFullName(): string
|
||||
{
|
||||
return $this->fullName;
|
||||
}
|
||||
|
||||
@ -207,7 +239,8 @@ class Repository extends AbstractApiModel {
|
||||
* Gets 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;
|
||||
}
|
||||
|
||||
@ -215,7 +248,8 @@ class Repository extends AbstractApiModel {
|
||||
* Gets the repository identifier.
|
||||
* @return int The repository identifier.
|
||||
*/
|
||||
function getId(): int {
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
@ -223,8 +257,11 @@ class Repository extends AbstractApiModel {
|
||||
* Gets the repository name.
|
||||
* @return string The repository name.
|
||||
*/
|
||||
function getName(): string {
|
||||
if (mb_strlen($this->name)) return $this->name;
|
||||
public function getName(): string
|
||||
{
|
||||
if (mb_strlen($this->name)) {
|
||||
return $this->name;
|
||||
}
|
||||
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.
|
||||
* @return int The number of open issues of this repository.
|
||||
*/
|
||||
function getOpenIssuesCount(): int {
|
||||
public function getOpenIssuesCount(): int
|
||||
{
|
||||
return $this->openIssuesCount;
|
||||
}
|
||||
|
||||
@ -240,7 +278,8 @@ class Repository extends AbstractApiModel {
|
||||
* Gets the repository owner.
|
||||
* @return User|null The repository owner.
|
||||
*/
|
||||
function getOwner(): ?Owner {
|
||||
public function getOwner(): ?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.
|
||||
* @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;
|
||||
}
|
||||
|
||||
@ -256,7 +296,8 @@ class Repository extends AbstractApiModel {
|
||||
* Gets the repository permissions.
|
||||
* @return Permission|null The repository permissions.
|
||||
*/
|
||||
function getPermissions(): ?Permission {
|
||||
public function getPermissions(): ?Permission
|
||||
{
|
||||
return $this->permissions;
|
||||
}
|
||||
|
||||
@ -264,7 +305,8 @@ class Repository extends AbstractApiModel {
|
||||
* Gets the repository size, in kilobytes.
|
||||
* @return int The repository size, in kilobytes.
|
||||
*/
|
||||
function getSize(): int {
|
||||
public function getSize(): int
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
@ -272,7 +314,8 @@ class Repository extends AbstractApiModel {
|
||||
* Gets 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;
|
||||
}
|
||||
|
||||
@ -280,15 +323,17 @@ class Repository extends AbstractApiModel {
|
||||
* Gets 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
@ -296,7 +341,8 @@ class Repository extends AbstractApiModel {
|
||||
* Gets 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;
|
||||
}
|
||||
|
||||
@ -304,7 +350,8 @@ class Repository extends AbstractApiModel {
|
||||
* Gets 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;
|
||||
}
|
||||
|
||||
@ -312,7 +359,8 @@ class Repository extends AbstractApiModel {
|
||||
* Gets a value indicating whether this repository is empty.
|
||||
* @return bool `true` if this repository is empty, otherwise `false`.
|
||||
*/
|
||||
function isEmpty(): bool {
|
||||
public function isEmpty(): bool
|
||||
{
|
||||
return $this->isEmpty;
|
||||
}
|
||||
|
||||
@ -320,7 +368,8 @@ class Repository extends AbstractApiModel {
|
||||
* Gets a value indicating whether this repository is a fork.
|
||||
* @return bool `true` if this repository is a fork, otherwise `false`.
|
||||
*/
|
||||
function isFork(): bool {
|
||||
public function isFork(): bool
|
||||
{
|
||||
return $this->isFork;
|
||||
}
|
||||
|
||||
@ -328,7 +377,8 @@ class Repository extends AbstractApiModel {
|
||||
* Gets a value indicating whether this repository is a mirror.
|
||||
* @return bool `true` if this repository is a mirror, otherwise `false`.
|
||||
*/
|
||||
function isMirror(): bool {
|
||||
public function isMirror(): bool
|
||||
{
|
||||
return $this->isMirror;
|
||||
}
|
||||
|
||||
@ -336,15 +386,17 @@ class Repository extends AbstractApiModel {
|
||||
* Gets a value indicating whether this repository is private.
|
||||
* @return bool `true` if this repository is private, otherwise `false`.
|
||||
*/
|
||||
function isPrivate(): bool {
|
||||
public function isPrivate(): bool
|
||||
{
|
||||
return $this->isPrivate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this object to a map in JSON format.
|
||||
* @return \stdClass The map in JSON format corresponding to this object.
|
||||
* @return stdClass The map in JSON format corresponding to this object.
|
||||
*/
|
||||
function jsonSerialize(): \stdClass {
|
||||
public function jsonSerialize(): stdClass
|
||||
{
|
||||
return (object) [
|
||||
'clone_url' => ($url = $this->getCloneUrl()) ? (string) $url : 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.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setCloneUrl(?UriInterface $value): self {
|
||||
public function setCloneUrl(?UriInterface $value): self
|
||||
{
|
||||
$this->cloneUrl = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the date the repository was created.
|
||||
* @param \DateTime|null $value The new date of creation.
|
||||
* @param DateTime|null $value The new date of creation.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setCreatedAt(?\DateTime $value): self {
|
||||
public function setCreatedAt(?DateTime $value): self
|
||||
{
|
||||
$this->createdAt = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -397,7 +451,8 @@ class Repository extends AbstractApiModel {
|
||||
* @param string $value The new default branch.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setDefaultBranch(string $value): self {
|
||||
public function setDefaultBranch(string $value): self
|
||||
{
|
||||
$this->defaultBranch = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -407,7 +462,8 @@ class Repository extends AbstractApiModel {
|
||||
* @param string $value The new repository description.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setDescription(string $value): self {
|
||||
public function setDescription(string $value): self
|
||||
{
|
||||
$this->description = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -417,7 +473,8 @@ class Repository extends AbstractApiModel {
|
||||
* @param bool $value `true` if this repository is empty, otherwise `false`.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setEmpty(bool $value): self {
|
||||
public function setEmpty(bool $value): self
|
||||
{
|
||||
$this->isEmpty = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -427,7 +484,8 @@ class Repository extends AbstractApiModel {
|
||||
* @param bool $value `true` if this repository is a fork, otherwise `false`.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setFork(bool $value): self {
|
||||
public function setFork(bool $value): self
|
||||
{
|
||||
$this->isFork = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -437,7 +495,8 @@ class Repository extends AbstractApiModel {
|
||||
* @param int $value The new number of forks.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setForksCount(int $value): self {
|
||||
public function setForksCount(int $value): self
|
||||
{
|
||||
$this->forksCount = max(0, $value);
|
||||
return $this;
|
||||
}
|
||||
@ -447,7 +506,8 @@ class Repository extends AbstractApiModel {
|
||||
* @param string $value The new full name.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setFullName(string $value): self {
|
||||
public function setFullName(string $value): self
|
||||
{
|
||||
$this->fullName = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -457,7 +517,8 @@ class Repository extends AbstractApiModel {
|
||||
* @param UriInterface|null $value The new Gitea URL.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setHtmlUrl(?UriInterface $value): self {
|
||||
public function setHtmlUrl(?UriInterface $value): self
|
||||
{
|
||||
$this->htmlUrl = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -467,7 +528,8 @@ class Repository extends AbstractApiModel {
|
||||
* @param bool $value `true` if this repository is a mirror, otherwise `false`.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setMirror(bool $value): self {
|
||||
public function setMirror(bool $value): self
|
||||
{
|
||||
$this->isMirror = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -477,7 +539,8 @@ class Repository extends AbstractApiModel {
|
||||
* @param string $value The new repository name.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setName(string $value): self {
|
||||
public function setName(string $value): self
|
||||
{
|
||||
$this->name = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -487,7 +550,8 @@ class Repository extends AbstractApiModel {
|
||||
* @param int $value The new number of open issues.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setOpenIssuesCount(int $value): self {
|
||||
public function setOpenIssuesCount(int $value): self
|
||||
{
|
||||
$this->openIssuesCount = max(0, $value);
|
||||
return $this;
|
||||
}
|
||||
@ -497,7 +561,8 @@ class Repository extends AbstractApiModel {
|
||||
* @param User|null $value The new owner.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setOwner(?Owner $value): self {
|
||||
public function setOwner(?Owner $value): self
|
||||
{
|
||||
$this->owner = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -507,7 +572,8 @@ class Repository extends AbstractApiModel {
|
||||
* @param Repository|null $value The new parent repository.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setParent(?Repository $value): self {
|
||||
public function setParent(?Repository $value): self
|
||||
{
|
||||
$this->parent = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -517,7 +583,8 @@ class Repository extends AbstractApiModel {
|
||||
* @param Permission|null $value The new permissions.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setPermissions(?Permission $value): self {
|
||||
public function setPermissions(?Permission $value): self
|
||||
{
|
||||
$this->permissions = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -527,7 +594,8 @@ class Repository extends AbstractApiModel {
|
||||
* @param bool $value `true` if this repository is private, otherwise `false`.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setPrivate(bool $value): self {
|
||||
public function setPrivate(bool $value): self
|
||||
{
|
||||
$this->isPrivate = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -537,7 +605,8 @@ class Repository extends AbstractApiModel {
|
||||
* @param int $value The new repository size, in kilobytes.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setSize(int $value): self {
|
||||
public function setSize(int $value): self
|
||||
{
|
||||
$this->size = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -547,7 +616,8 @@ class Repository extends AbstractApiModel {
|
||||
* @param UriInterface|null $value The new URL for cloning this repository.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setSshUrl(?UriInterface $value): self {
|
||||
public function setSshUrl(?UriInterface $value): self
|
||||
{
|
||||
$this->sshUrl = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -557,17 +627,19 @@ class Repository extends AbstractApiModel {
|
||||
* @param int $value The new number of stars.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setStarsCount(int $value): self {
|
||||
public function setStarsCount(int $value): self
|
||||
{
|
||||
$this->starsCount = max(0, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the date the repository was updated.
|
||||
* @param \DateTime|null $value The new date of update.
|
||||
* @param DateTime|null $value The new date of update.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setUpdatedAt(?\DateTime $value): self {
|
||||
public function setUpdatedAt(?DateTime $value): self
|
||||
{
|
||||
$this->updatedAt = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -577,7 +649,8 @@ class Repository extends AbstractApiModel {
|
||||
* @param int $value The new number of watchers.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setWatchersCount(int $value): self {
|
||||
public function setWatchersCount(int $value): self
|
||||
{
|
||||
$this->watchersCount = max(0, $value);
|
||||
return $this;
|
||||
}
|
||||
@ -587,7 +660,8 @@ class Repository extends AbstractApiModel {
|
||||
* @param UriInterface|null $value The new repository website.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setWebsite(?UriInterface $value): self {
|
||||
public function setWebsite(?UriInterface $value): self
|
||||
{
|
||||
$this->website = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -644,5 +718,4 @@ class Repository extends AbstractApiModel {
|
||||
return $tagsApi->fromRepository($owner->getUsername(), $this->getName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,9 +1,14 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Gitea\Model;
|
||||
|
||||
/** Wraps the version of the Gitea server. */
|
||||
class ServerVersion implements \JsonSerializable {
|
||||
use stdClass;
|
||||
use JsonSerializable;
|
||||
|
||||
/** Wraps the version of the Gitea server. */
|
||||
class ServerVersion implements JsonSerializable
|
||||
{
|
||||
/** @var string The version number. */
|
||||
private $version;
|
||||
|
||||
@ -11,7 +16,8 @@ class ServerVersion implements \JsonSerializable {
|
||||
* Creates a new server version.
|
||||
* @param string $version The version number.
|
||||
*/
|
||||
function __construct(string $version) {
|
||||
public function __construct(string $version)
|
||||
{
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
@ -20,7 +26,8 @@ class ServerVersion implements \JsonSerializable {
|
||||
* @param object $map A JSON map representing a server version.
|
||||
* @return static The instance corresponding to the specified JSON map.
|
||||
*/
|
||||
static function fromJson(object $map): self {
|
||||
public static function fromJson(object $map): self
|
||||
{
|
||||
return new static(isset($map->version) && is_string($map->version) ? $map->version : '');
|
||||
}
|
||||
|
||||
@ -28,15 +35,17 @@ class ServerVersion implements \JsonSerializable {
|
||||
* Gets the version number.
|
||||
* @return string The version number.
|
||||
*/
|
||||
function getVersion(): string {
|
||||
public function getVersion(): string
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this object to a map in JSON format.
|
||||
* @return \stdClass The map in JSON format corresponding to this object.
|
||||
* @return stdClass The map in JSON format corresponding to this object.
|
||||
*/
|
||||
function jsonSerialize(): \stdClass {
|
||||
public function jsonSerialize(): stdClass
|
||||
{
|
||||
return (object) ['version' => $this->getVersion()];
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,8 +7,8 @@ namespace Gitea\Model;
|
||||
use MyCLabs\Enum\Enum;
|
||||
|
||||
/** Defines the state of a Gitea status. */
|
||||
final class StatusState extends Enum {
|
||||
|
||||
final class StatusState extends Enum
|
||||
{
|
||||
/** @var string The status is an error. */
|
||||
const error = 'error';
|
||||
|
||||
|
||||
@ -7,23 +7,24 @@ use Psr\Http\Message\UriInterface;
|
||||
|
||||
use Gitea\Client;
|
||||
|
||||
use \InvalidArgumentException;
|
||||
use stdClass;
|
||||
use InvalidArgumentException;
|
||||
|
||||
use Gitea\Model\Abstracts\AbstractApiModel;
|
||||
|
||||
/** Represents a Gitea tag. */
|
||||
class Tag extends AbstractApiModel {
|
||||
|
||||
class Tag extends AbstractApiModel
|
||||
{
|
||||
/** @var int The tag identifier. */
|
||||
private $id = -1;
|
||||
|
||||
/** @var string The tag's name. */
|
||||
private $name = '';
|
||||
|
||||
/** @var string The tarball URL for the tag */
|
||||
/** @var UriInterface The tarball URL for the tag */
|
||||
private $tarballURL;
|
||||
|
||||
/** @var string The zipball URL for the tag */
|
||||
/** @var UriInterface The zipball URL for the tag */
|
||||
private $zipballURL;
|
||||
|
||||
/** @var int The commit information for the tag */
|
||||
@ -39,7 +40,8 @@ class Tag extends AbstractApiModel {
|
||||
* @param int|string $id The tag identifier
|
||||
* @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);
|
||||
if (count($args) >= 2) {
|
||||
$id = $args[0];
|
||||
@ -67,7 +69,8 @@ class Tag extends AbstractApiModel {
|
||||
* @param object $map A JSON map representing an tag.
|
||||
* @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(
|
||||
$client,
|
||||
$caller,
|
||||
@ -85,9 +88,10 @@ class Tag extends AbstractApiModel {
|
||||
|
||||
/**
|
||||
* 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) [
|
||||
'id' => $this->getId(),
|
||||
'name' => $this->getName(),
|
||||
@ -104,55 +108,65 @@ class Tag extends AbstractApiModel {
|
||||
* Gets the tag identifier.
|
||||
* @return int The tag identifier.
|
||||
*/
|
||||
function getId(): string {
|
||||
public function getId(): string
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($name): self {
|
||||
public function setName($name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTarballURL(): ?UriInterface {
|
||||
public function getTarballURL(): ?UriInterface
|
||||
{
|
||||
return $this->tarballURL;
|
||||
}
|
||||
|
||||
public function setTarballURL(?UriInterface $url): self {
|
||||
public function setTarballURL(?UriInterface $url): self
|
||||
{
|
||||
$this->tarballURL = $url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getZipballURL(): ?UriInterface {
|
||||
public function getZipballURL(): ?UriInterface
|
||||
{
|
||||
return $this->zipballURL;
|
||||
}
|
||||
|
||||
public function setZipballURL(?UriInterface $url): self {
|
||||
public function setZipballURL(?UriInterface $url): self
|
||||
{
|
||||
$this->zipballURL = $url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCommitSha(): string {
|
||||
public function getCommitSha(): string
|
||||
{
|
||||
$commit = $this->commit;
|
||||
return $commit["sha"];
|
||||
}
|
||||
|
||||
public function setCommitSha(string $string): self {
|
||||
public function setCommitSha(string $string): self
|
||||
{
|
||||
$this->commit["sha"] = $string;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCommitUrl(): ?uri {
|
||||
public function getCommitUrl(): ?uri
|
||||
{
|
||||
$commit = $this->commit;
|
||||
return $commit["url"];
|
||||
}
|
||||
|
||||
public function setCommitUrl(?uri $url): self {
|
||||
public function setCommitUrl(?uri $url): self
|
||||
{
|
||||
$this->commit["url"] = $url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,9 +1,14 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Gitea\Model;
|
||||
|
||||
/** Represents a team in an organization. */
|
||||
class Team implements \JsonSerializable {
|
||||
use stdClass;
|
||||
use JsonSerializable;
|
||||
|
||||
/** Represents a team in an organization. */
|
||||
class Team implements JsonSerializable
|
||||
{
|
||||
/** @var string The team description. */
|
||||
private $description = '';
|
||||
|
||||
@ -21,7 +26,8 @@ class Team implements \JsonSerializable {
|
||||
* @param int $id The team identifier.
|
||||
* @param string $name The team name.
|
||||
*/
|
||||
function __construct(int $id, string $name) {
|
||||
public function __construct(int $id, string $name)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->setName($name);
|
||||
}
|
||||
@ -31,7 +37,8 @@ class Team implements \JsonSerializable {
|
||||
* @param object $map A JSON map representing a user.
|
||||
* @return static The instance corresponding to the specified JSON map.
|
||||
*/
|
||||
static function fromJson(object $map): self {
|
||||
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 : ''))
|
||||
->setDescription(isset($map->description) && is_string($map->description) ? $map->description : '')
|
||||
->setPermission(isset($map->permission) && is_string($map->permission) ? $map->permission : TeamPermission::none);
|
||||
@ -41,7 +48,8 @@ class Team implements \JsonSerializable {
|
||||
* Gets the team description.
|
||||
* @return string The team description.
|
||||
*/
|
||||
function getDescription(): string {
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
@ -49,7 +57,8 @@ class Team implements \JsonSerializable {
|
||||
* Gets the team identifier.
|
||||
* @return int The team identifier.
|
||||
*/
|
||||
function getId(): int {
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
@ -57,7 +66,8 @@ class Team implements \JsonSerializable {
|
||||
* Gets the team name.
|
||||
* @return string The team name.
|
||||
*/
|
||||
function getName(): string {
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
@ -65,15 +75,17 @@ class Team implements \JsonSerializable {
|
||||
* Gets the team permission.
|
||||
* @return string The team permission.
|
||||
*/
|
||||
function getPermission(): string {
|
||||
public function getPermission(): string
|
||||
{
|
||||
return $this->permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this object to a map in JSON format.
|
||||
* @return \stdClass The map in JSON format corresponding to this object.
|
||||
* @return stdClass The map in JSON format corresponding to this object.
|
||||
*/
|
||||
function jsonSerialize(): \stdClass {
|
||||
public function jsonSerialize(): stdClass
|
||||
{
|
||||
return (object) [
|
||||
'description' => $this->getDescription(),
|
||||
'id' => $this->getId(),
|
||||
@ -87,7 +99,8 @@ class Team implements \JsonSerializable {
|
||||
* @param string $value The new description.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setDescription(string $value): self {
|
||||
public function setDescription(string $value): self
|
||||
{
|
||||
$this->description = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -97,7 +110,8 @@ class Team implements \JsonSerializable {
|
||||
* @param string $value The new name.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setName(string $value): self {
|
||||
public function setName(string $value): self
|
||||
{
|
||||
$this->name = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -107,7 +121,8 @@ class Team implements \JsonSerializable {
|
||||
* @param string $value The new permission.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setPermission(string $value): self {
|
||||
public function setPermission(string $value): self
|
||||
{
|
||||
$this->permission = TeamPermission::coerce($value, TeamPermission::none);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Gitea\Model;
|
||||
|
||||
use MyCLabs\Enum\Enum;
|
||||
|
||||
/** Defines the permission of a team. */
|
||||
final class TeamPermission extends Enum {
|
||||
|
||||
final class TeamPermission extends Enum
|
||||
{
|
||||
/** @var string The team has the administrator permission. */
|
||||
const admin = 'admin';
|
||||
|
||||
|
||||
@ -1,10 +1,16 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Gitea\Model;
|
||||
|
||||
/** Represents the worked time for an issue or pull request. */
|
||||
class TrackedTime implements \JsonSerializable {
|
||||
use stdClass;
|
||||
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;
|
||||
|
||||
/** @var int The entry identifier. */
|
||||
@ -24,7 +30,8 @@ class TrackedTime implements \JsonSerializable {
|
||||
* @param int $id The entry identifier.
|
||||
* @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->setTime($time);
|
||||
}
|
||||
@ -34,18 +41,24 @@ class TrackedTime implements \JsonSerializable {
|
||||
* @param object $map A JSON map representing an entry.
|
||||
* @return static The instance corresponding to the specified JSON map.
|
||||
*/
|
||||
static function fromJson(object $map): self {
|
||||
return (new static(isset($map->id) && is_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)
|
||||
->setUserId(isset($map->user_id) && is_numeric($map->user_id) ? $map->user_id : -1);
|
||||
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)
|
||||
->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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
@ -53,7 +66,8 @@ class TrackedTime implements \JsonSerializable {
|
||||
* Gets the entry identifier.
|
||||
* @return int The entry identifier.
|
||||
*/
|
||||
function getId(): int {
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
@ -61,7 +75,8 @@ class TrackedTime implements \JsonSerializable {
|
||||
* Gets 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;
|
||||
}
|
||||
|
||||
@ -69,7 +84,8 @@ class TrackedTime implements \JsonSerializable {
|
||||
* Gets the elapsed time, in seconds.
|
||||
* @return int The elapsed time, in seconds.
|
||||
*/
|
||||
function getTime(): int {
|
||||
public function getTime(): int
|
||||
{
|
||||
return $this->time;
|
||||
}
|
||||
|
||||
@ -77,15 +93,17 @@ class TrackedTime implements \JsonSerializable {
|
||||
* Gets the identifier of the initiating user.
|
||||
* @return int The identifier of the initiating user.
|
||||
*/
|
||||
function getUserId(): int {
|
||||
public function getUserId(): int
|
||||
{
|
||||
return $this->userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this object to a map in JSON format.
|
||||
* @return \stdClass The map in JSON format corresponding to this object.
|
||||
* @return stdClass The map in JSON format corresponding to this object.
|
||||
*/
|
||||
function jsonSerialize(): \stdClass {
|
||||
public function jsonSerialize(): stdClass
|
||||
{
|
||||
return (object) [
|
||||
'created' => ($date = $this->getCreatedAt()) ? $date->format('c') : null,
|
||||
'id' => $this->getId(),
|
||||
@ -97,10 +115,11 @@ class TrackedTime implements \JsonSerializable {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
function setCreatedAt(?\DateTime $value): self {
|
||||
public function setCreatedAt(?DateTime $value): self
|
||||
{
|
||||
$this->createdAt = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -110,7 +129,8 @@ class TrackedTime implements \JsonSerializable {
|
||||
* @param int $value The new issue identifier.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setIssueId(int $value): self {
|
||||
public function setIssueId(int $value): self
|
||||
{
|
||||
$this->issueId = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -120,7 +140,8 @@ class TrackedTime implements \JsonSerializable {
|
||||
* @param int $value The new elapsed time, in seconds.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setTime(int $value): self {
|
||||
public function setTime(int $value): self
|
||||
{
|
||||
$this->time = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -130,7 +151,8 @@ class TrackedTime implements \JsonSerializable {
|
||||
* @param int $value The new user identifier.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setUserId(int $value): self {
|
||||
public function setUserId(int $value): self
|
||||
{
|
||||
$this->userId = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -1,12 +1,17 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Gitea\Model;
|
||||
|
||||
use GuzzleHttp\Psr7\{Uri};
|
||||
use Psr\Http\Message\{UriInterface};
|
||||
|
||||
/** Represents a Gitea user. */
|
||||
class User implements \JsonSerializable {
|
||||
use stdClass;
|
||||
use JsonSerializable;
|
||||
|
||||
/** Represents a Gitea user. */
|
||||
class User implements JsonSerializable
|
||||
{
|
||||
/** @var UriInterface|null The URL to the user's avatar. */
|
||||
private $avatarUrl;
|
||||
|
||||
@ -30,7 +35,8 @@ class User implements \JsonSerializable {
|
||||
* @param int $id The user identifier.
|
||||
* @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->setLogin($login);
|
||||
}
|
||||
@ -40,19 +46,25 @@ class User implements \JsonSerializable {
|
||||
* @param object $map A JSON map representing a user.
|
||||
* @return static The instance corresponding to the specified JSON map.
|
||||
*/
|
||||
static function fromJson(object $map): self {
|
||||
return (new static(isset($map->id) && is_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)
|
||||
->setEmail(isset($map->email) && is_string($map->email) ? mb_strtolower($map->email) : '')
|
||||
->setFullName(isset($map->full_name) && is_string($map->full_name) ? $map->full_name : '')
|
||||
->setLanguage(isset($map->language) && is_string($map->language) ? $map->language : '');
|
||||
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 : '')
|
||||
)
|
||||
->setAvatarUrl(isset($map->avatar_url) && is_string($map->avatar_url) ? new Uri($map->avatar_url) : null)
|
||||
->setEmail(isset($map->email) && is_string($map->email) ? mb_strtolower($map->email) : '')
|
||||
->setFullName(isset($map->full_name) && is_string($map->full_name) ? $map->full_name : '')
|
||||
->setLanguage(isset($map->language) && is_string($map->language) ? $map->language : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the URL of the avatar image.
|
||||
* @return UriInterface|null The URL of the avatar image.
|
||||
*/
|
||||
function getAvatarUrl(): ?UriInterface {
|
||||
public function getAvatarUrl(): ?UriInterface
|
||||
{
|
||||
return $this->avatarUrl;
|
||||
}
|
||||
|
||||
@ -60,7 +72,8 @@ class User implements \JsonSerializable {
|
||||
* Gets the mail address.
|
||||
* @return string The mail address.
|
||||
*/
|
||||
function getEmail(): string {
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
@ -68,7 +81,8 @@ class User implements \JsonSerializable {
|
||||
* Gets the full name.
|
||||
* @return string The full name.
|
||||
*/
|
||||
function getFullName(): string {
|
||||
public function getFullName(): string
|
||||
{
|
||||
return $this->fullName;
|
||||
}
|
||||
|
||||
@ -76,7 +90,8 @@ class User implements \JsonSerializable {
|
||||
* Gets the user identifier.
|
||||
* @return int The user identifier.
|
||||
*/
|
||||
function getId(): int {
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
@ -84,7 +99,8 @@ class User implements \JsonSerializable {
|
||||
* Gets the user locale.
|
||||
* @return string The user locale.
|
||||
*/
|
||||
function getLanguage(): string {
|
||||
public function getLanguage(): string
|
||||
{
|
||||
return $this->language;
|
||||
}
|
||||
|
||||
@ -92,15 +108,17 @@ class User implements \JsonSerializable {
|
||||
* Gets the name of the Gitea account.
|
||||
* @return string The name of the Gitea account.
|
||||
*/
|
||||
function getLogin(): string {
|
||||
public function getLogin(): string
|
||||
{
|
||||
return $this->login;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this object to a map in JSON format.
|
||||
* @return \stdClass The map in JSON format corresponding to this object.
|
||||
* @return stdClass The map in JSON format corresponding to this object.
|
||||
*/
|
||||
function jsonSerialize(): \stdClass {
|
||||
public function jsonSerialize(): stdClass
|
||||
{
|
||||
return (object) [
|
||||
'avatar_url' => ($url = $this->getAvatarUrl()) ? (string) $url : null,
|
||||
'email' => $this->getEmail(),
|
||||
@ -116,7 +134,8 @@ class User implements \JsonSerializable {
|
||||
* @param UriInterface|null $value The new avatar URL.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setAvatarUrl(?UriInterface $value): self {
|
||||
public function setAvatarUrl(?UriInterface $value): self
|
||||
{
|
||||
$this->avatarUrl = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -126,7 +145,8 @@ class User implements \JsonSerializable {
|
||||
* @param string $value The new mail address.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setEmail(string $value): self {
|
||||
public function setEmail(string $value): self
|
||||
{
|
||||
$this->email = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -136,7 +156,8 @@ class User implements \JsonSerializable {
|
||||
* @param string $value The new full name.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setFullName(string $value): self {
|
||||
public function setFullName(string $value): self
|
||||
{
|
||||
$this->fullName = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -146,7 +167,8 @@ class User implements \JsonSerializable {
|
||||
* @param string $value The new user locale.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setLanguage(string $value): self {
|
||||
public function setLanguage(string $value): self
|
||||
{
|
||||
$this->language = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -156,7 +178,8 @@ class User implements \JsonSerializable {
|
||||
* @param string $value The new Gitea account.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setLogin(string $value): self {
|
||||
public function setLogin(string $value): self
|
||||
{
|
||||
$this->login = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -9,11 +9,13 @@ use GuzzleHttp\Exception\ClientException;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
||||
use stdClass;
|
||||
|
||||
use Gitea\Model\Abstracts\AbstractApiModel;
|
||||
|
||||
/** Represents a Gitea push event. */
|
||||
class PushEvent extends AbstractApiModel {
|
||||
|
||||
class PushEvent extends AbstractApiModel
|
||||
{
|
||||
/** @var string The hash of the new Git revision. */
|
||||
private $after = '';
|
||||
|
||||
@ -42,8 +44,9 @@ class PushEvent extends AbstractApiModel {
|
||||
private $sender;
|
||||
|
||||
/** Creates a new event. */
|
||||
function __construct(Client &$client, ?object $caller, ...$args) {
|
||||
$this->commits = new \ArrayObject;
|
||||
public function __construct(Client &$client, ?object $caller, ...$args)
|
||||
{
|
||||
$this->commits = new \ArrayObject();
|
||||
parent::__construct($client, $caller, ...$args);
|
||||
}
|
||||
|
||||
@ -93,7 +96,9 @@ class PushEvent extends AbstractApiModel {
|
||||
|
||||
// check payload signature against header 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.
|
||||
* @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(
|
||||
$client,
|
||||
$caller
|
||||
@ -119,7 +125,7 @@ class PushEvent extends AbstractApiModel {
|
||||
->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);
|
||||
|
||||
if(isset($map->commits) && is_array($map->commits)) {
|
||||
if (isset($map->commits) && is_array($map->commits)) {
|
||||
$commitsArray = [];
|
||||
foreach ($map->commits as $commit) {
|
||||
$commitsArray[] = PayloadCommit::fromJson($client, null, $commit);
|
||||
@ -134,7 +140,8 @@ class PushEvent extends AbstractApiModel {
|
||||
* Gets 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;
|
||||
}
|
||||
|
||||
@ -142,7 +149,8 @@ class PushEvent extends AbstractApiModel {
|
||||
* Gets the hash of the new previous revision.
|
||||
* @return string The hash of the previous Git revision.
|
||||
*/
|
||||
function getBefore(): string {
|
||||
public function getBefore(): string
|
||||
{
|
||||
return $this->before;
|
||||
}
|
||||
|
||||
@ -150,7 +158,8 @@ class PushEvent extends AbstractApiModel {
|
||||
* Gets the revision commits.
|
||||
* @return \ArrayObject The revision commits.
|
||||
*/
|
||||
function getCommits(): \ArrayObject {
|
||||
public function getCommits(): \ArrayObject
|
||||
{
|
||||
return $this->commits;
|
||||
}
|
||||
|
||||
@ -158,7 +167,8 @@ class PushEvent extends AbstractApiModel {
|
||||
* Gets 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;
|
||||
}
|
||||
|
||||
@ -166,7 +176,8 @@ class PushEvent extends AbstractApiModel {
|
||||
* Gets 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;
|
||||
}
|
||||
|
||||
@ -174,7 +185,8 @@ class PushEvent extends AbstractApiModel {
|
||||
* Gets the Git reference.
|
||||
* @return string The Git reference.
|
||||
*/
|
||||
function getRef(): string {
|
||||
public function getRef(): string
|
||||
{
|
||||
return $this->ref;
|
||||
}
|
||||
|
||||
@ -182,7 +194,8 @@ class PushEvent extends AbstractApiModel {
|
||||
* Gets 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;
|
||||
}
|
||||
|
||||
@ -190,7 +203,8 @@ class PushEvent extends AbstractApiModel {
|
||||
* Gets 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;
|
||||
}
|
||||
|
||||
@ -198,20 +212,27 @@ class PushEvent extends AbstractApiModel {
|
||||
* Gets 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) [
|
||||
'after' => $this->getAfter(),
|
||||
'before' => $this->getBefore(),
|
||||
'compare_url' => ($url = $this->getCompareUrl()) ? (string) $url : null,
|
||||
'commits' => array_map(function(PayloadCommit $commit) { return $commit->jsonSerialize(); }, $this->getCommits()->getArrayCopy()),
|
||||
'commits' => array_map(
|
||||
function (PayloadCommit $commit) {
|
||||
return $commit->jsonSerialize();
|
||||
},
|
||||
$this->getCommits()->getArrayCopy()
|
||||
),
|
||||
'pusher' => ($user = $this->getPusher()) ? $user->jsonSerialize() : null,
|
||||
'ref' => $this->getRef(),
|
||||
'repository' => ($repository = $this->getRepository()) ? $repository->jsonSerialize() : null,
|
||||
@ -224,7 +245,8 @@ class PushEvent extends AbstractApiModel {
|
||||
* @param string $value The hash of the new Git revision.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setAfter(string $value): self {
|
||||
public function setAfter(string $value): self
|
||||
{
|
||||
$this->after = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -234,7 +256,8 @@ class PushEvent extends AbstractApiModel {
|
||||
* @param string $value The hash of the new previous revision.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setBefore(string $value): self {
|
||||
public function setBefore(string $value): self
|
||||
{
|
||||
$this->before = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -244,7 +267,8 @@ class PushEvent extends AbstractApiModel {
|
||||
* @param PayloadCommit[] $values The revision commits.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setCommits(array $values): self {
|
||||
public function setCommits(array $values): self
|
||||
{
|
||||
$this->getCommits()->exchangeArray($values);
|
||||
return $this;
|
||||
}
|
||||
@ -254,7 +278,8 @@ class PushEvent extends AbstractApiModel {
|
||||
* @param UriInterface|null $value The URL for comparing the revisions.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setCompareUrl(?UriInterface $value): self {
|
||||
public function setCompareUrl(?UriInterface $value): self
|
||||
{
|
||||
$this->compareUrl = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -264,7 +289,8 @@ class PushEvent extends AbstractApiModel {
|
||||
* @param User|null $value The new pusher.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setPusher(?User $value): self {
|
||||
public function setPusher(?User $value): self
|
||||
{
|
||||
$this->pusher = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -274,7 +300,8 @@ class PushEvent extends AbstractApiModel {
|
||||
* @param string $value The new Git reference.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setRef(string $value): self {
|
||||
public function setRef(string $value): self
|
||||
{
|
||||
$this->ref = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -284,7 +311,8 @@ class PushEvent extends AbstractApiModel {
|
||||
* @param Repository|null $value The new repository.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setRepository(?Repository $value): self {
|
||||
public function setRepository(?Repository $value): self
|
||||
{
|
||||
$this->repository = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -294,7 +322,8 @@ class PushEvent extends AbstractApiModel {
|
||||
* @param string $value The new secret used to validate this event.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setSecret(string $value): self {
|
||||
public function setSecret(string $value): self
|
||||
{
|
||||
$this->secret = $value;
|
||||
return $this;
|
||||
}
|
||||
@ -304,7 +333,8 @@ class PushEvent extends AbstractApiModel {
|
||||
* @param User|null $value The new sender.
|
||||
* @return $this This instance.
|
||||
*/
|
||||
function setSender(?User $value): self {
|
||||
public function setSender(?User $value): self
|
||||
{
|
||||
$this->sender = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ if ($repository) {
|
||||
if ($foundObj) {
|
||||
print("Repository class found \n");
|
||||
print("Type: ".get_class($foundObj)." \n");
|
||||
} else{
|
||||
} else {
|
||||
print("Repository class NOT found \n");
|
||||
}
|
||||
print("\n\n");
|
||||
|
||||
Reference in New Issue
Block a user