@@ -13,38 +13,38 @@ |
||
| 13 | 13 | class Markdown extends AbstractMiscellaneous |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Render an arbitrary Markdown document |
|
| 18 | - * |
|
| 19 | - * @link https://developer.github.com/v3/markdown/#render-an-arbitrary-markdown-document |
|
| 20 | - * |
|
| 21 | - * @param string $text The Markdown text to render |
|
| 22 | - * @param string $mode The rendering mode. |
|
| 23 | - * @param string $context The repository context. Only taken into account when rendering as gfm |
|
| 24 | - * |
|
| 25 | - * @return array |
|
| 26 | - */ |
|
| 27 | - public function render(string $text, string $mode = AbstractApi::MODE_MARKDOWN, string $context = ''): array |
|
| 28 | - { |
|
| 29 | - return $this->getApi()->request('/markdown', Request::METHOD_POST, [ |
|
| 30 | - 'text' => $text, |
|
| 31 | - 'mode' => $mode, |
|
| 32 | - 'context' => $context |
|
| 33 | - ]); |
|
| 34 | - } |
|
| 16 | + /** |
|
| 17 | + * Render an arbitrary Markdown document |
|
| 18 | + * |
|
| 19 | + * @link https://developer.github.com/v3/markdown/#render-an-arbitrary-markdown-document |
|
| 20 | + * |
|
| 21 | + * @param string $text The Markdown text to render |
|
| 22 | + * @param string $mode The rendering mode. |
|
| 23 | + * @param string $context The repository context. Only taken into account when rendering as gfm |
|
| 24 | + * |
|
| 25 | + * @return array |
|
| 26 | + */ |
|
| 27 | + public function render(string $text, string $mode = AbstractApi::MODE_MARKDOWN, string $context = ''): array |
|
| 28 | + { |
|
| 29 | + return $this->getApi()->request('/markdown', Request::METHOD_POST, [ |
|
| 30 | + 'text' => $text, |
|
| 31 | + 'mode' => $mode, |
|
| 32 | + 'context' => $context |
|
| 33 | + ]); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Render a Markdown document in raw mode |
|
| 38 | - * |
|
| 39 | - * @link https://developer.github.com/v3/markdown/#render-a-markdown-document-in-raw-mode |
|
| 40 | - * |
|
| 41 | - * @param string $string |
|
| 42 | - * |
|
| 43 | - * @return array |
|
| 44 | - */ |
|
| 45 | - public function renderRaw(string $string): array |
|
| 46 | - { |
|
| 47 | - return $this->getApi()->setContentType('text/plain') |
|
| 48 | - ->request('/markdown/raw', Request::METHOD_POST, ['file' => $string]); |
|
| 49 | - } |
|
| 36 | + /** |
|
| 37 | + * Render a Markdown document in raw mode |
|
| 38 | + * |
|
| 39 | + * @link https://developer.github.com/v3/markdown/#render-a-markdown-document-in-raw-mode |
|
| 40 | + * |
|
| 41 | + * @param string $string |
|
| 42 | + * |
|
| 43 | + * @return array |
|
| 44 | + */ |
|
| 45 | + public function renderRaw(string $string): array |
|
| 46 | + { |
|
| 47 | + return $this->getApi()->setContentType('text/plain') |
|
| 48 | + ->request('/markdown/raw', Request::METHOD_POST, ['file' => $string]); |
|
| 49 | + } |
|
| 50 | 50 | } |
| 51 | 51 | \ No newline at end of file |
@@ -12,44 +12,44 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | abstract class AbstractRepositories |
| 14 | 14 | { |
| 15 | - /** Api trait */ |
|
| 16 | - use Api; |
|
| 15 | + /** Api trait */ |
|
| 16 | + use Api; |
|
| 17 | 17 | |
| 18 | - /** Properties */ |
|
| 19 | - protected $repositories; |
|
| 18 | + /** Properties */ |
|
| 19 | + protected $repositories; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Constructor |
|
| 23 | - * |
|
| 24 | - * @param Repositories $repositories |
|
| 25 | - */ |
|
| 26 | - public function __construct(Repositories $repositories) |
|
| 27 | - { |
|
| 28 | - $this->setRepositories($repositories); |
|
| 29 | - $this->setApi($repositories->getApi()); |
|
| 30 | - } |
|
| 21 | + /** |
|
| 22 | + * Constructor |
|
| 23 | + * |
|
| 24 | + * @param Repositories $repositories |
|
| 25 | + */ |
|
| 26 | + public function __construct(Repositories $repositories) |
|
| 27 | + { |
|
| 28 | + $this->setRepositories($repositories); |
|
| 29 | + $this->setApi($repositories->getApi()); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Get repositories |
|
| 34 | - * |
|
| 35 | - * @return Repositories |
|
| 36 | - */ |
|
| 37 | - public function getRepositories(): Repositories |
|
| 38 | - { |
|
| 39 | - return $this->repositories; |
|
| 40 | - } |
|
| 32 | + /** |
|
| 33 | + * Get repositories |
|
| 34 | + * |
|
| 35 | + * @return Repositories |
|
| 36 | + */ |
|
| 37 | + public function getRepositories(): Repositories |
|
| 38 | + { |
|
| 39 | + return $this->repositories; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Set repositories |
|
| 44 | - * |
|
| 45 | - * @param Repositories $repositories |
|
| 46 | - * |
|
| 47 | - * @return AbstractRepositories |
|
| 48 | - */ |
|
| 49 | - public function setRepositories(Repositories $repositories): AbstractRepositories |
|
| 50 | - { |
|
| 51 | - $this->repositories = $repositories; |
|
| 42 | + /** |
|
| 43 | + * Set repositories |
|
| 44 | + * |
|
| 45 | + * @param Repositories $repositories |
|
| 46 | + * |
|
| 47 | + * @return AbstractRepositories |
|
| 48 | + */ |
|
| 49 | + public function setRepositories(Repositories $repositories): AbstractRepositories |
|
| 50 | + { |
|
| 51 | + $this->repositories = $repositories; |
|
| 52 | 52 | |
| 53 | - return $this; |
|
| 54 | - } |
|
| 53 | + return $this; |
|
| 54 | + } |
|
| 55 | 55 | } |
| 56 | 56 | \ No newline at end of file |
@@ -12,44 +12,44 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | abstract class AbstractEnterprise |
| 14 | 14 | { |
| 15 | - /** Api trait */ |
|
| 16 | - use Api; |
|
| 15 | + /** Api trait */ |
|
| 16 | + use Api; |
|
| 17 | 17 | |
| 18 | - /** Properties */ |
|
| 19 | - protected $enterprise; |
|
| 18 | + /** Properties */ |
|
| 19 | + protected $enterprise; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Constructor |
|
| 23 | - * |
|
| 24 | - * @param Enterprise $enterprise |
|
| 25 | - */ |
|
| 26 | - public function __construct(Enterprise $enterprise) |
|
| 27 | - { |
|
| 28 | - $this->setEnterprise($enterprise); |
|
| 29 | - $this->setApi($enterprise->getApi()); |
|
| 30 | - } |
|
| 21 | + /** |
|
| 22 | + * Constructor |
|
| 23 | + * |
|
| 24 | + * @param Enterprise $enterprise |
|
| 25 | + */ |
|
| 26 | + public function __construct(Enterprise $enterprise) |
|
| 27 | + { |
|
| 28 | + $this->setEnterprise($enterprise); |
|
| 29 | + $this->setApi($enterprise->getApi()); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Get enterprise |
|
| 34 | - * |
|
| 35 | - * @return Enterprise |
|
| 36 | - */ |
|
| 37 | - public function getEnterprise(): Enterprise |
|
| 38 | - { |
|
| 39 | - return $this->enterprise; |
|
| 40 | - } |
|
| 32 | + /** |
|
| 33 | + * Get enterprise |
|
| 34 | + * |
|
| 35 | + * @return Enterprise |
|
| 36 | + */ |
|
| 37 | + public function getEnterprise(): Enterprise |
|
| 38 | + { |
|
| 39 | + return $this->enterprise; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Set enterprise |
|
| 44 | - * |
|
| 45 | - * @param Enterprise $enterprise |
|
| 46 | - * |
|
| 47 | - * @return AbstractEnterprise |
|
| 48 | - */ |
|
| 49 | - public function setEnterprise(Enterprise $enterprise): AbstractEnterprise |
|
| 50 | - { |
|
| 51 | - $this->enterprise = $enterprise; |
|
| 42 | + /** |
|
| 43 | + * Set enterprise |
|
| 44 | + * |
|
| 45 | + * @param Enterprise $enterprise |
|
| 46 | + * |
|
| 47 | + * @return AbstractEnterprise |
|
| 48 | + */ |
|
| 49 | + public function setEnterprise(Enterprise $enterprise): AbstractEnterprise |
|
| 50 | + { |
|
| 51 | + $this->enterprise = $enterprise; |
|
| 52 | 52 | |
| 53 | - return $this; |
|
| 54 | - } |
|
| 53 | + return $this; |
|
| 54 | + } |
|
| 55 | 55 | } |
| 56 | 56 | \ No newline at end of file |
@@ -3,9 +3,9 @@ discard block |
||
| 3 | 3 | |
| 4 | 4 | use FlexyProject\GitHub\AbstractApi; |
| 5 | 5 | use FlexyProject\GitHub\Receiver\{ |
| 6 | - Activity\AbstractActivity, Enterprise\AbstractEnterprise, Gists\AbstractGists, GitData\AbstractGitData, |
|
| 7 | - Issues\AbstractIssues, Miscellaneous\AbstractMiscellaneous, Organizations\AbstractOrganizations, |
|
| 8 | - PullRequests\AbstractPullRequests, Repositories\AbstractRepositories |
|
| 6 | + Activity\AbstractActivity, Enterprise\AbstractEnterprise, Gists\AbstractGists, GitData\AbstractGitData, |
|
| 7 | + Issues\AbstractIssues, Miscellaneous\AbstractMiscellaneous, Organizations\AbstractOrganizations, |
|
| 8 | + PullRequests\AbstractPullRequests, Repositories\AbstractRepositories |
|
| 9 | 9 | }; |
| 10 | 10 | |
| 11 | 11 | /** |
@@ -15,30 +15,30 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | trait Api |
| 17 | 17 | { |
| 18 | - /** @var mixed */ |
|
| 19 | - protected $api; |
|
| 18 | + /** @var mixed */ |
|
| 19 | + protected $api; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Get api |
|
| 23 | - * |
|
| 24 | - * @return AbstractApi|AbstractActivity|AbstractEnterprise|AbstractGists|AbstractGitData|AbstractIssues|AbstractMiscellaneous|AbstractOrganizations|AbstractPullRequests|AbstractRepositories |
|
| 25 | - */ |
|
| 26 | - public function getApi() |
|
| 27 | - { |
|
| 28 | - return $this->api; |
|
| 29 | - } |
|
| 21 | + /** |
|
| 22 | + * Get api |
|
| 23 | + * |
|
| 24 | + * @return AbstractApi|AbstractActivity|AbstractEnterprise|AbstractGists|AbstractGitData|AbstractIssues|AbstractMiscellaneous|AbstractOrganizations|AbstractPullRequests|AbstractRepositories |
|
| 25 | + */ |
|
| 26 | + public function getApi() |
|
| 27 | + { |
|
| 28 | + return $this->api; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Set api |
|
| 33 | - * |
|
| 34 | - * @param AbstractApi|AbstractActivity|AbstractEnterprise|AbstractGists|AbstractGitData|AbstractIssues|AbstractMiscellaneous|AbstractOrganizations|AbstractPullRequests|AbstractRepositories $api |
|
| 35 | - * |
|
| 36 | - * @return Api |
|
| 37 | - */ |
|
| 38 | - public function setApi($api): self |
|
| 39 | - { |
|
| 40 | - $this->api = $api; |
|
| 31 | + /** |
|
| 32 | + * Set api |
|
| 33 | + * |
|
| 34 | + * @param AbstractApi|AbstractActivity|AbstractEnterprise|AbstractGists|AbstractGitData|AbstractIssues|AbstractMiscellaneous|AbstractOrganizations|AbstractPullRequests|AbstractRepositories $api |
|
| 35 | + * |
|
| 36 | + * @return Api |
|
| 37 | + */ |
|
| 38 | + public function setApi($api): self |
|
| 39 | + { |
|
| 40 | + $this->api = $api; |
|
| 41 | 41 | |
| 42 | - return $this; |
|
| 43 | - } |
|
| 42 | + return $this; |
|
| 43 | + } |
|
| 44 | 44 | } |
| 45 | 45 | \ No newline at end of file |
@@ -13,321 +13,321 @@ |
||
| 13 | 13 | class Repositories extends AbstractReceiver |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - /** Available sub-Receiver */ |
|
| 17 | - const COLLABORATORS = 'Collaborators'; |
|
| 18 | - const COMMENTS = 'Comments'; |
|
| 19 | - const COMMITS = 'Commits'; |
|
| 20 | - const CONTENTS = 'Contents'; |
|
| 21 | - const DEPLOY_KEYS = 'DeployKeys'; |
|
| 22 | - const DEPLOYMENTS = 'Deployments'; |
|
| 23 | - const FORKS = 'Forks'; |
|
| 24 | - const HOOKS = 'Hooks'; |
|
| 25 | - const MERGING = 'Merging'; |
|
| 26 | - const PAGES = 'Pages'; |
|
| 27 | - const RELEASES = 'Releases'; |
|
| 28 | - const STATISTICS = 'Statistics'; |
|
| 29 | - const STATUSES = 'Statuses'; |
|
| 16 | + /** Available sub-Receiver */ |
|
| 17 | + const COLLABORATORS = 'Collaborators'; |
|
| 18 | + const COMMENTS = 'Comments'; |
|
| 19 | + const COMMITS = 'Commits'; |
|
| 20 | + const CONTENTS = 'Contents'; |
|
| 21 | + const DEPLOY_KEYS = 'DeployKeys'; |
|
| 22 | + const DEPLOYMENTS = 'Deployments'; |
|
| 23 | + const FORKS = 'Forks'; |
|
| 24 | + const HOOKS = 'Hooks'; |
|
| 25 | + const MERGING = 'Merging'; |
|
| 26 | + const PAGES = 'Pages'; |
|
| 27 | + const RELEASES = 'Releases'; |
|
| 28 | + const STATISTICS = 'Statistics'; |
|
| 29 | + const STATUSES = 'Statuses'; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * List repositories for the authenticated user. |
|
| 33 | - * |
|
| 34 | - * @link https://developer.github.com/v3/repos/#list-your-repositories |
|
| 35 | - * |
|
| 36 | - * @param string $type |
|
| 37 | - * @param string $sort |
|
| 38 | - * @param string $direction |
|
| 39 | - * |
|
| 40 | - * @return array |
|
| 41 | - */ |
|
| 42 | - public function listYourRepositories(string $type = AbstractApi::TYPE_ALL, |
|
| 43 | - string $sort = AbstractApi::SORT_FULL_NAME, |
|
| 44 | - string $direction = AbstractApi::DIRECTION_DESC): array |
|
| 45 | - { |
|
| 46 | - return $this->getApi()->request($this->getApi()->sprintf('/user/repos?:args', |
|
| 47 | - http_build_query(['type' => $type, 'sort' => $sort, 'direction' => $direction]))); |
|
| 48 | - } |
|
| 31 | + /** |
|
| 32 | + * List repositories for the authenticated user. |
|
| 33 | + * |
|
| 34 | + * @link https://developer.github.com/v3/repos/#list-your-repositories |
|
| 35 | + * |
|
| 36 | + * @param string $type |
|
| 37 | + * @param string $sort |
|
| 38 | + * @param string $direction |
|
| 39 | + * |
|
| 40 | + * @return array |
|
| 41 | + */ |
|
| 42 | + public function listYourRepositories(string $type = AbstractApi::TYPE_ALL, |
|
| 43 | + string $sort = AbstractApi::SORT_FULL_NAME, |
|
| 44 | + string $direction = AbstractApi::DIRECTION_DESC): array |
|
| 45 | + { |
|
| 46 | + return $this->getApi()->request($this->getApi()->sprintf('/user/repos?:args', |
|
| 47 | + http_build_query(['type' => $type, 'sort' => $sort, 'direction' => $direction]))); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * List public repositories for the specified user. |
|
| 52 | - * |
|
| 53 | - * @link https://developer.github.com/v3/repos/#list-user-repositories |
|
| 54 | - * |
|
| 55 | - * @param string $username |
|
| 56 | - * @param string $type |
|
| 57 | - * @param string $sort |
|
| 58 | - * @param string $direction |
|
| 59 | - * |
|
| 60 | - * @return array |
|
| 61 | - */ |
|
| 62 | - public function listUserRepositories(string $username, string $type = AbstractApi::TYPE_OWNER, |
|
| 63 | - string $sort = AbstractApi::SORT_FULL_NAME, |
|
| 64 | - string $direction = AbstractApi::DIRECTION_DESC): array |
|
| 65 | - { |
|
| 66 | - return $this->getApi()->request($this->getApi()->sprintf('/users/:username/repos?:args', $username, |
|
| 67 | - http_build_query(['type' => $type, 'sort' => $sort, 'direction' => $direction]))); |
|
| 68 | - } |
|
| 50 | + /** |
|
| 51 | + * List public repositories for the specified user. |
|
| 52 | + * |
|
| 53 | + * @link https://developer.github.com/v3/repos/#list-user-repositories |
|
| 54 | + * |
|
| 55 | + * @param string $username |
|
| 56 | + * @param string $type |
|
| 57 | + * @param string $sort |
|
| 58 | + * @param string $direction |
|
| 59 | + * |
|
| 60 | + * @return array |
|
| 61 | + */ |
|
| 62 | + public function listUserRepositories(string $username, string $type = AbstractApi::TYPE_OWNER, |
|
| 63 | + string $sort = AbstractApi::SORT_FULL_NAME, |
|
| 64 | + string $direction = AbstractApi::DIRECTION_DESC): array |
|
| 65 | + { |
|
| 66 | + return $this->getApi()->request($this->getApi()->sprintf('/users/:username/repos?:args', $username, |
|
| 67 | + http_build_query(['type' => $type, 'sort' => $sort, 'direction' => $direction]))); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * List repositories for the specified org. |
|
| 72 | - * |
|
| 73 | - * @link https://developer.github.com/v3/repos/#list-organization-repositories |
|
| 74 | - * |
|
| 75 | - * @param string $organization |
|
| 76 | - * @param string $type |
|
| 77 | - * |
|
| 78 | - * @return array |
|
| 79 | - */ |
|
| 80 | - public function listOrganizationRepositories(string $organization, string $type = AbstractApi::TYPE_ALL): array |
|
| 81 | - { |
|
| 82 | - return $this->getApi()->request($this->getApi()->sprintf('/orgs/:org/repos?:args', $organization, |
|
| 83 | - http_build_query(['type' => $type]))); |
|
| 84 | - } |
|
| 70 | + /** |
|
| 71 | + * List repositories for the specified org. |
|
| 72 | + * |
|
| 73 | + * @link https://developer.github.com/v3/repos/#list-organization-repositories |
|
| 74 | + * |
|
| 75 | + * @param string $organization |
|
| 76 | + * @param string $type |
|
| 77 | + * |
|
| 78 | + * @return array |
|
| 79 | + */ |
|
| 80 | + public function listOrganizationRepositories(string $organization, string $type = AbstractApi::TYPE_ALL): array |
|
| 81 | + { |
|
| 82 | + return $this->getApi()->request($this->getApi()->sprintf('/orgs/:org/repos?:args', $organization, |
|
| 83 | + http_build_query(['type' => $type]))); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * List all public repositories |
|
| 88 | - * |
|
| 89 | - * @link https://developer.github.com/v3/repos/#list-all-public-repositories |
|
| 90 | - * |
|
| 91 | - * @param string $since |
|
| 92 | - * |
|
| 93 | - * @return array |
|
| 94 | - */ |
|
| 95 | - public function listPublicRepositories(string $since = '1970-01-01'): array |
|
| 96 | - { |
|
| 97 | - return $this->getApi()->request($this->getApi() |
|
| 98 | - ->sprintf('/repositories?:arg', http_build_query(['since', $since]))); |
|
| 99 | - } |
|
| 86 | + /** |
|
| 87 | + * List all public repositories |
|
| 88 | + * |
|
| 89 | + * @link https://developer.github.com/v3/repos/#list-all-public-repositories |
|
| 90 | + * |
|
| 91 | + * @param string $since |
|
| 92 | + * |
|
| 93 | + * @return array |
|
| 94 | + */ |
|
| 95 | + public function listPublicRepositories(string $since = '1970-01-01'): array |
|
| 96 | + { |
|
| 97 | + return $this->getApi()->request($this->getApi() |
|
| 98 | + ->sprintf('/repositories?:arg', http_build_query(['since', $since]))); |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * Create a new repository for the authenticated user. |
|
| 103 | - * |
|
| 104 | - * @link https://developer.github.com/v3/repos/#create |
|
| 105 | - * |
|
| 106 | - * @param string $name |
|
| 107 | - * @param string $description |
|
| 108 | - * @param string $homepage |
|
| 109 | - * @param bool $private |
|
| 110 | - * @param bool $hasIssues |
|
| 111 | - * @param bool $hasWiki |
|
| 112 | - * @param bool $hasDownloads |
|
| 113 | - * @param int $teamId |
|
| 114 | - * @param bool $autoInit |
|
| 115 | - * @param string $gitignoreTemplate |
|
| 116 | - * @param string $licenseTemplate |
|
| 117 | - * |
|
| 118 | - * @return array |
|
| 119 | - */ |
|
| 120 | - public function createRepository(string $name, string $description = '', string $homepage = '', |
|
| 121 | - bool $private = false, bool $hasIssues = true, bool $hasWiki = true, |
|
| 122 | - bool $hasDownloads = true, int $teamId = 0, bool $autoInit = false, |
|
| 123 | - string $gitignoreTemplate = '', string $licenseTemplate = ''): array |
|
| 124 | - { |
|
| 125 | - return $this->getApi()->request(sprintf('/user/repos'), Request::METHOD_POST, [ |
|
| 126 | - 'name' => $name, |
|
| 127 | - 'description' => $description, |
|
| 128 | - 'homepage' => $homepage, |
|
| 129 | - 'private' => $private, |
|
| 130 | - 'has_issues' => $hasIssues, |
|
| 131 | - 'has_wiki' => $hasWiki, |
|
| 132 | - 'has_downloads' => $hasDownloads, |
|
| 133 | - 'team_id' => $teamId, |
|
| 134 | - 'auto_init' => $autoInit, |
|
| 135 | - 'gitignore_template' => $gitignoreTemplate, |
|
| 136 | - 'license_template' => $licenseTemplate |
|
| 137 | - ]); |
|
| 138 | - } |
|
| 101 | + /** |
|
| 102 | + * Create a new repository for the authenticated user. |
|
| 103 | + * |
|
| 104 | + * @link https://developer.github.com/v3/repos/#create |
|
| 105 | + * |
|
| 106 | + * @param string $name |
|
| 107 | + * @param string $description |
|
| 108 | + * @param string $homepage |
|
| 109 | + * @param bool $private |
|
| 110 | + * @param bool $hasIssues |
|
| 111 | + * @param bool $hasWiki |
|
| 112 | + * @param bool $hasDownloads |
|
| 113 | + * @param int $teamId |
|
| 114 | + * @param bool $autoInit |
|
| 115 | + * @param string $gitignoreTemplate |
|
| 116 | + * @param string $licenseTemplate |
|
| 117 | + * |
|
| 118 | + * @return array |
|
| 119 | + */ |
|
| 120 | + public function createRepository(string $name, string $description = '', string $homepage = '', |
|
| 121 | + bool $private = false, bool $hasIssues = true, bool $hasWiki = true, |
|
| 122 | + bool $hasDownloads = true, int $teamId = 0, bool $autoInit = false, |
|
| 123 | + string $gitignoreTemplate = '', string $licenseTemplate = ''): array |
|
| 124 | + { |
|
| 125 | + return $this->getApi()->request(sprintf('/user/repos'), Request::METHOD_POST, [ |
|
| 126 | + 'name' => $name, |
|
| 127 | + 'description' => $description, |
|
| 128 | + 'homepage' => $homepage, |
|
| 129 | + 'private' => $private, |
|
| 130 | + 'has_issues' => $hasIssues, |
|
| 131 | + 'has_wiki' => $hasWiki, |
|
| 132 | + 'has_downloads' => $hasDownloads, |
|
| 133 | + 'team_id' => $teamId, |
|
| 134 | + 'auto_init' => $autoInit, |
|
| 135 | + 'gitignore_template' => $gitignoreTemplate, |
|
| 136 | + 'license_template' => $licenseTemplate |
|
| 137 | + ]); |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - /** |
|
| 141 | - * Create a new repository in this organization. The authenticated user must be a member of the specified |
|
| 142 | - * organization. |
|
| 143 | - * |
|
| 144 | - * @link https://developer.github.com/v3/repos/#create |
|
| 145 | - * |
|
| 146 | - * @param string $organization |
|
| 147 | - * @param string $name |
|
| 148 | - * @param string $description |
|
| 149 | - * @param string $homepage |
|
| 150 | - * @param bool $private |
|
| 151 | - * @param bool $hasIssues |
|
| 152 | - * @param bool $hasWiki |
|
| 153 | - * @param bool $hasDownloads |
|
| 154 | - * @param int $teamId |
|
| 155 | - * @param bool $autoInit |
|
| 156 | - * @param string $gitignoreTemplate |
|
| 157 | - * @param string $licenseTemplate |
|
| 158 | - * |
|
| 159 | - * @return array |
|
| 160 | - */ |
|
| 161 | - public function createOrganizationRepository(string $organization, string $name, string $description = '', |
|
| 162 | - string $homepage = '', bool $private = false, bool $hasIssues = true, |
|
| 163 | - bool $hasWiki = true, bool $hasDownloads = true, int $teamId = 0, |
|
| 164 | - bool $autoInit = false, string $gitignoreTemplate = '', |
|
| 165 | - string $licenseTemplate = ''): array |
|
| 166 | - { |
|
| 167 | - return $this->getApi()->request($this->getApi()->sprintf('/orgs/:org/repos', $organization), |
|
| 168 | - Request::METHOD_POST, [ |
|
| 169 | - 'name' => $name, |
|
| 170 | - 'description' => $description, |
|
| 171 | - 'homepage' => $homepage, |
|
| 172 | - 'private' => $private, |
|
| 173 | - 'has_issues' => $hasIssues, |
|
| 174 | - 'has_wiki' => $hasWiki, |
|
| 175 | - 'has_downloads' => $hasDownloads, |
|
| 176 | - 'team_id' => $teamId, |
|
| 177 | - 'auto_init' => $autoInit, |
|
| 178 | - 'gitignore_template' => $gitignoreTemplate, |
|
| 179 | - 'license_template' => $licenseTemplate |
|
| 180 | - ]); |
|
| 181 | - } |
|
| 140 | + /** |
|
| 141 | + * Create a new repository in this organization. The authenticated user must be a member of the specified |
|
| 142 | + * organization. |
|
| 143 | + * |
|
| 144 | + * @link https://developer.github.com/v3/repos/#create |
|
| 145 | + * |
|
| 146 | + * @param string $organization |
|
| 147 | + * @param string $name |
|
| 148 | + * @param string $description |
|
| 149 | + * @param string $homepage |
|
| 150 | + * @param bool $private |
|
| 151 | + * @param bool $hasIssues |
|
| 152 | + * @param bool $hasWiki |
|
| 153 | + * @param bool $hasDownloads |
|
| 154 | + * @param int $teamId |
|
| 155 | + * @param bool $autoInit |
|
| 156 | + * @param string $gitignoreTemplate |
|
| 157 | + * @param string $licenseTemplate |
|
| 158 | + * |
|
| 159 | + * @return array |
|
| 160 | + */ |
|
| 161 | + public function createOrganizationRepository(string $organization, string $name, string $description = '', |
|
| 162 | + string $homepage = '', bool $private = false, bool $hasIssues = true, |
|
| 163 | + bool $hasWiki = true, bool $hasDownloads = true, int $teamId = 0, |
|
| 164 | + bool $autoInit = false, string $gitignoreTemplate = '', |
|
| 165 | + string $licenseTemplate = ''): array |
|
| 166 | + { |
|
| 167 | + return $this->getApi()->request($this->getApi()->sprintf('/orgs/:org/repos', $organization), |
|
| 168 | + Request::METHOD_POST, [ |
|
| 169 | + 'name' => $name, |
|
| 170 | + 'description' => $description, |
|
| 171 | + 'homepage' => $homepage, |
|
| 172 | + 'private' => $private, |
|
| 173 | + 'has_issues' => $hasIssues, |
|
| 174 | + 'has_wiki' => $hasWiki, |
|
| 175 | + 'has_downloads' => $hasDownloads, |
|
| 176 | + 'team_id' => $teamId, |
|
| 177 | + 'auto_init' => $autoInit, |
|
| 178 | + 'gitignore_template' => $gitignoreTemplate, |
|
| 179 | + 'license_template' => $licenseTemplate |
|
| 180 | + ]); |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - /** |
|
| 184 | - * Get |
|
| 185 | - * |
|
| 186 | - * @link https://developer.github.com/v3/repos/#get |
|
| 187 | - * @return array |
|
| 188 | - */ |
|
| 189 | - public function get(): array |
|
| 190 | - { |
|
| 191 | - return $this->getApi()->request($this->getApi() |
|
| 192 | - ->sprintf('/repos/:owner/:repo', $this->getOwner(), $this->getRepo())); |
|
| 193 | - } |
|
| 183 | + /** |
|
| 184 | + * Get |
|
| 185 | + * |
|
| 186 | + * @link https://developer.github.com/v3/repos/#get |
|
| 187 | + * @return array |
|
| 188 | + */ |
|
| 189 | + public function get(): array |
|
| 190 | + { |
|
| 191 | + return $this->getApi()->request($this->getApi() |
|
| 192 | + ->sprintf('/repos/:owner/:repo', $this->getOwner(), $this->getRepo())); |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | - /** |
|
| 196 | - * Edit |
|
| 197 | - * |
|
| 198 | - * @link https://developer.github.com/v3/repos/#edit |
|
| 199 | - * |
|
| 200 | - * @param string $name |
|
| 201 | - * @param string $description |
|
| 202 | - * @param string $homepage |
|
| 203 | - * @param bool $private |
|
| 204 | - * @param bool $hasIssues |
|
| 205 | - * @param bool $hasWiki |
|
| 206 | - * @param bool $hasDownloads |
|
| 207 | - * @param string $defaultBranch |
|
| 208 | - * |
|
| 209 | - * @return array |
|
| 210 | - */ |
|
| 211 | - public function edit(string $name, string $description = '', string $homepage = '', bool $private = false, |
|
| 212 | - bool $hasIssues = true, bool $hasWiki = true, bool $hasDownloads = true, |
|
| 213 | - string $defaultBranch = ''): array |
|
| 214 | - { |
|
| 215 | - return $this->getApi()->request($this->getApi() |
|
| 216 | - ->sprintf('/repos/:owner/:repo', $this->getOwner(), $this->getRepo()), |
|
| 217 | - Request::METHOD_PATCH, [ |
|
| 218 | - 'name' => $name, |
|
| 219 | - 'description' => $description, |
|
| 220 | - 'homepage' => $homepage, |
|
| 221 | - 'private' => $private, |
|
| 222 | - 'has_issues' => $hasIssues, |
|
| 223 | - 'has_wiki' => $hasWiki, |
|
| 224 | - 'has_downloads' => $hasDownloads, |
|
| 225 | - 'default_branch' => $defaultBranch |
|
| 226 | - ]); |
|
| 227 | - } |
|
| 195 | + /** |
|
| 196 | + * Edit |
|
| 197 | + * |
|
| 198 | + * @link https://developer.github.com/v3/repos/#edit |
|
| 199 | + * |
|
| 200 | + * @param string $name |
|
| 201 | + * @param string $description |
|
| 202 | + * @param string $homepage |
|
| 203 | + * @param bool $private |
|
| 204 | + * @param bool $hasIssues |
|
| 205 | + * @param bool $hasWiki |
|
| 206 | + * @param bool $hasDownloads |
|
| 207 | + * @param string $defaultBranch |
|
| 208 | + * |
|
| 209 | + * @return array |
|
| 210 | + */ |
|
| 211 | + public function edit(string $name, string $description = '', string $homepage = '', bool $private = false, |
|
| 212 | + bool $hasIssues = true, bool $hasWiki = true, bool $hasDownloads = true, |
|
| 213 | + string $defaultBranch = ''): array |
|
| 214 | + { |
|
| 215 | + return $this->getApi()->request($this->getApi() |
|
| 216 | + ->sprintf('/repos/:owner/:repo', $this->getOwner(), $this->getRepo()), |
|
| 217 | + Request::METHOD_PATCH, [ |
|
| 218 | + 'name' => $name, |
|
| 219 | + 'description' => $description, |
|
| 220 | + 'homepage' => $homepage, |
|
| 221 | + 'private' => $private, |
|
| 222 | + 'has_issues' => $hasIssues, |
|
| 223 | + 'has_wiki' => $hasWiki, |
|
| 224 | + 'has_downloads' => $hasDownloads, |
|
| 225 | + 'default_branch' => $defaultBranch |
|
| 226 | + ]); |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - /** |
|
| 230 | - * List contributors |
|
| 231 | - * |
|
| 232 | - * @link https://developer.github.com/v3/repos/#list-contributors |
|
| 233 | - * |
|
| 234 | - * @param string $anon |
|
| 235 | - * |
|
| 236 | - * @return array |
|
| 237 | - */ |
|
| 238 | - public function listContributors(string $anon = '0'): array |
|
| 239 | - { |
|
| 240 | - return $this->getApi()->request($this->getApi() |
|
| 241 | - ->sprintf('/repos/:owner/:repo/contributors?:args', $this->getOwner(), |
|
| 242 | - $this->getRepo(), http_build_query(['anon' => $anon]))); |
|
| 243 | - } |
|
| 229 | + /** |
|
| 230 | + * List contributors |
|
| 231 | + * |
|
| 232 | + * @link https://developer.github.com/v3/repos/#list-contributors |
|
| 233 | + * |
|
| 234 | + * @param string $anon |
|
| 235 | + * |
|
| 236 | + * @return array |
|
| 237 | + */ |
|
| 238 | + public function listContributors(string $anon = '0'): array |
|
| 239 | + { |
|
| 240 | + return $this->getApi()->request($this->getApi() |
|
| 241 | + ->sprintf('/repos/:owner/:repo/contributors?:args', $this->getOwner(), |
|
| 242 | + $this->getRepo(), http_build_query(['anon' => $anon]))); |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - /** |
|
| 246 | - * List languages |
|
| 247 | - * |
|
| 248 | - * @link https://developer.github.com/v3/repos/#list-languages |
|
| 249 | - * @return array |
|
| 250 | - */ |
|
| 251 | - public function listLanguages(): array |
|
| 252 | - { |
|
| 253 | - return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/languages', $this->getOwner(), |
|
| 254 | - $this->getRepo())); |
|
| 255 | - } |
|
| 245 | + /** |
|
| 246 | + * List languages |
|
| 247 | + * |
|
| 248 | + * @link https://developer.github.com/v3/repos/#list-languages |
|
| 249 | + * @return array |
|
| 250 | + */ |
|
| 251 | + public function listLanguages(): array |
|
| 252 | + { |
|
| 253 | + return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/languages', $this->getOwner(), |
|
| 254 | + $this->getRepo())); |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | - /** |
|
| 258 | - * List Teams |
|
| 259 | - * |
|
| 260 | - * @link https://developer.github.com/v3/repos/#list-teams |
|
| 261 | - * @return array |
|
| 262 | - */ |
|
| 263 | - public function listTeams(): array |
|
| 264 | - { |
|
| 265 | - return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/teams', $this->getOwner(), |
|
| 266 | - $this->getRepo())); |
|
| 267 | - } |
|
| 257 | + /** |
|
| 258 | + * List Teams |
|
| 259 | + * |
|
| 260 | + * @link https://developer.github.com/v3/repos/#list-teams |
|
| 261 | + * @return array |
|
| 262 | + */ |
|
| 263 | + public function listTeams(): array |
|
| 264 | + { |
|
| 265 | + return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/teams', $this->getOwner(), |
|
| 266 | + $this->getRepo())); |
|
| 267 | + } |
|
| 268 | 268 | |
| 269 | - /** |
|
| 270 | - * List Tags |
|
| 271 | - * |
|
| 272 | - * @link https://developer.github.com/v3/repos/#list-tags |
|
| 273 | - * @return array |
|
| 274 | - */ |
|
| 275 | - public function listTags(): array |
|
| 276 | - { |
|
| 277 | - return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/tags', $this->getOwner(), |
|
| 278 | - $this->getRepo())); |
|
| 279 | - } |
|
| 269 | + /** |
|
| 270 | + * List Tags |
|
| 271 | + * |
|
| 272 | + * @link https://developer.github.com/v3/repos/#list-tags |
|
| 273 | + * @return array |
|
| 274 | + */ |
|
| 275 | + public function listTags(): array |
|
| 276 | + { |
|
| 277 | + return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/tags', $this->getOwner(), |
|
| 278 | + $this->getRepo())); |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - /** |
|
| 282 | - * List Branches |
|
| 283 | - * |
|
| 284 | - * @link https://developer.github.com/v3/repos/#list-branches |
|
| 285 | - * @return array |
|
| 286 | - */ |
|
| 287 | - public function listBranches(): array |
|
| 288 | - { |
|
| 289 | - return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/branches', $this->getOwner(), |
|
| 290 | - $this->getRepo())); |
|
| 291 | - } |
|
| 281 | + /** |
|
| 282 | + * List Branches |
|
| 283 | + * |
|
| 284 | + * @link https://developer.github.com/v3/repos/#list-branches |
|
| 285 | + * @return array |
|
| 286 | + */ |
|
| 287 | + public function listBranches(): array |
|
| 288 | + { |
|
| 289 | + return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/branches', $this->getOwner(), |
|
| 290 | + $this->getRepo())); |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | - /** |
|
| 294 | - * Get Branch |
|
| 295 | - * |
|
| 296 | - * @link https://developer.github.com/v3/repos/#get-branch |
|
| 297 | - * |
|
| 298 | - * @param string $branch |
|
| 299 | - * |
|
| 300 | - * @return array |
|
| 301 | - */ |
|
| 302 | - public function getBranch(string $branch): array |
|
| 303 | - { |
|
| 304 | - return $this->getApi()->request($this->getApi() |
|
| 305 | - ->sprintf('/repos/:owner/:repo/branches/:branch', $this->getOwner(), |
|
| 306 | - $this->getRepo(), $branch)); |
|
| 307 | - } |
|
| 293 | + /** |
|
| 294 | + * Get Branch |
|
| 295 | + * |
|
| 296 | + * @link https://developer.github.com/v3/repos/#get-branch |
|
| 297 | + * |
|
| 298 | + * @param string $branch |
|
| 299 | + * |
|
| 300 | + * @return array |
|
| 301 | + */ |
|
| 302 | + public function getBranch(string $branch): array |
|
| 303 | + { |
|
| 304 | + return $this->getApi()->request($this->getApi() |
|
| 305 | + ->sprintf('/repos/:owner/:repo/branches/:branch', $this->getOwner(), |
|
| 306 | + $this->getRepo(), $branch)); |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | - /** |
|
| 310 | - * Delete a Repository |
|
| 311 | - * |
|
| 312 | - * @link https://developer.github.com/v3/repos/#delete-a-repository |
|
| 313 | - * @return array |
|
| 314 | - */ |
|
| 315 | - public function deleteRepository(): array |
|
| 316 | - { |
|
| 317 | - return $this->getApi()->request($this->getApi() |
|
| 318 | - ->sprintf('/repos/:owner/:repo', $this->getOwner(), $this->getRepo()), |
|
| 319 | - Request::METHOD_DELETE); |
|
| 320 | - } |
|
| 309 | + /** |
|
| 310 | + * Delete a Repository |
|
| 311 | + * |
|
| 312 | + * @link https://developer.github.com/v3/repos/#delete-a-repository |
|
| 313 | + * @return array |
|
| 314 | + */ |
|
| 315 | + public function deleteRepository(): array |
|
| 316 | + { |
|
| 317 | + return $this->getApi()->request($this->getApi() |
|
| 318 | + ->sprintf('/repos/:owner/:repo', $this->getOwner(), $this->getRepo()), |
|
| 319 | + Request::METHOD_DELETE); |
|
| 320 | + } |
|
| 321 | 321 | |
| 322 | - /** |
|
| 323 | - * Get the contents of a repository's license |
|
| 324 | - * |
|
| 325 | - * @link https://developer.github.com/v3/licenses/#get-the-contents-of-a-repositorys-license |
|
| 326 | - * @return array |
|
| 327 | - */ |
|
| 328 | - public function getRepositoryLicenseContent(): array |
|
| 329 | - { |
|
| 330 | - return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/license', $this->getOwner(), |
|
| 331 | - $this->getRepo())); |
|
| 332 | - } |
|
| 322 | + /** |
|
| 323 | + * Get the contents of a repository's license |
|
| 324 | + * |
|
| 325 | + * @link https://developer.github.com/v3/licenses/#get-the-contents-of-a-repositorys-license |
|
| 326 | + * @return array |
|
| 327 | + */ |
|
| 328 | + public function getRepositoryLicenseContent(): array |
|
| 329 | + { |
|
| 330 | + return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/license', $this->getOwner(), |
|
| 331 | + $this->getRepo())); |
|
| 332 | + } |
|
| 333 | 333 | } |
| 334 | 334 | \ No newline at end of file |
@@ -12,44 +12,44 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | abstract class AbstractIssues |
| 14 | 14 | { |
| 15 | - /** Api trait */ |
|
| 16 | - use Api; |
|
| 15 | + /** Api trait */ |
|
| 16 | + use Api; |
|
| 17 | 17 | |
| 18 | - /** Properties */ |
|
| 19 | - protected $issues; |
|
| 18 | + /** Properties */ |
|
| 19 | + protected $issues; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Constructor |
|
| 23 | - * |
|
| 24 | - * @param Issues $issues |
|
| 25 | - */ |
|
| 26 | - public function __construct(Issues $issues) |
|
| 27 | - { |
|
| 28 | - $this->setIssues($issues); |
|
| 29 | - $this->setApi($issues->getApi()); |
|
| 30 | - } |
|
| 21 | + /** |
|
| 22 | + * Constructor |
|
| 23 | + * |
|
| 24 | + * @param Issues $issues |
|
| 25 | + */ |
|
| 26 | + public function __construct(Issues $issues) |
|
| 27 | + { |
|
| 28 | + $this->setIssues($issues); |
|
| 29 | + $this->setApi($issues->getApi()); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Get issues |
|
| 34 | - * |
|
| 35 | - * @return Issues |
|
| 36 | - */ |
|
| 37 | - public function getIssues(): Issues |
|
| 38 | - { |
|
| 39 | - return $this->issues; |
|
| 40 | - } |
|
| 32 | + /** |
|
| 33 | + * Get issues |
|
| 34 | + * |
|
| 35 | + * @return Issues |
|
| 36 | + */ |
|
| 37 | + public function getIssues(): Issues |
|
| 38 | + { |
|
| 39 | + return $this->issues; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Set issues |
|
| 44 | - * |
|
| 45 | - * @param Issues $issues |
|
| 46 | - * |
|
| 47 | - * @return AbstractIssues |
|
| 48 | - */ |
|
| 49 | - public function setIssues(Issues $issues): AbstractIssues |
|
| 50 | - { |
|
| 51 | - $this->issues = $issues; |
|
| 42 | + /** |
|
| 43 | + * Set issues |
|
| 44 | + * |
|
| 45 | + * @param Issues $issues |
|
| 46 | + * |
|
| 47 | + * @return AbstractIssues |
|
| 48 | + */ |
|
| 49 | + public function setIssues(Issues $issues): AbstractIssues |
|
| 50 | + { |
|
| 51 | + $this->issues = $issues; |
|
| 52 | 52 | |
| 53 | - return $this; |
|
| 54 | - } |
|
| 53 | + return $this; |
|
| 54 | + } |
|
| 55 | 55 | } |
| 56 | 56 | \ No newline at end of file |
@@ -12,44 +12,44 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | abstract class AbstractActivity |
| 14 | 14 | { |
| 15 | - /** Api trait */ |
|
| 16 | - use Api; |
|
| 15 | + /** Api trait */ |
|
| 16 | + use Api; |
|
| 17 | 17 | |
| 18 | - /** Properties */ |
|
| 19 | - protected $activity; |
|
| 18 | + /** Properties */ |
|
| 19 | + protected $activity; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Constructor |
|
| 23 | - * |
|
| 24 | - * @param Activity $activity |
|
| 25 | - */ |
|
| 26 | - public function __construct(Activity $activity) |
|
| 27 | - { |
|
| 28 | - $this->setActivity($activity); |
|
| 29 | - $this->setApi($activity->getApi()); |
|
| 30 | - } |
|
| 21 | + /** |
|
| 22 | + * Constructor |
|
| 23 | + * |
|
| 24 | + * @param Activity $activity |
|
| 25 | + */ |
|
| 26 | + public function __construct(Activity $activity) |
|
| 27 | + { |
|
| 28 | + $this->setActivity($activity); |
|
| 29 | + $this->setApi($activity->getApi()); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Get activity |
|
| 34 | - * |
|
| 35 | - * @return Activity |
|
| 36 | - */ |
|
| 37 | - public function getActivity(): Activity |
|
| 38 | - { |
|
| 39 | - return $this->activity; |
|
| 40 | - } |
|
| 32 | + /** |
|
| 33 | + * Get activity |
|
| 34 | + * |
|
| 35 | + * @return Activity |
|
| 36 | + */ |
|
| 37 | + public function getActivity(): Activity |
|
| 38 | + { |
|
| 39 | + return $this->activity; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Set activity |
|
| 44 | - * |
|
| 45 | - * @param Activity $activity |
|
| 46 | - * |
|
| 47 | - * @return AbstractActivity |
|
| 48 | - */ |
|
| 49 | - public function setActivity(Activity $activity): AbstractActivity |
|
| 50 | - { |
|
| 51 | - $this->activity = $activity; |
|
| 42 | + /** |
|
| 43 | + * Set activity |
|
| 44 | + * |
|
| 45 | + * @param Activity $activity |
|
| 46 | + * |
|
| 47 | + * @return AbstractActivity |
|
| 48 | + */ |
|
| 49 | + public function setActivity(Activity $activity): AbstractActivity |
|
| 50 | + { |
|
| 51 | + $this->activity = $activity; |
|
| 52 | 52 | |
| 53 | - return $this; |
|
| 54 | - } |
|
| 53 | + return $this; |
|
| 54 | + } |
|
| 55 | 55 | } |
| 56 | 56 | \ No newline at end of file |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | namespace FlexyProject\GitHub\Tests\Receiver; |
| 3 | 3 | |
| 4 | 4 | use FlexyProject\GitHub\{ |
| 5 | - AbstractApi, Client, Receiver\Miscellaneous, Tests\AbstractTest |
|
| 5 | + AbstractApi, Client, Receiver\Miscellaneous, Tests\AbstractTest |
|
| 6 | 6 | }; |
| 7 | 7 | |
| 8 | 8 | /** |
@@ -13,153 +13,153 @@ discard block |
||
| 13 | 13 | class MiscellaneousTest extends AbstractTest |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - /** @var Miscellaneous */ |
|
| 17 | - protected $miscellaneous; |
|
| 18 | - |
|
| 19 | - /** @var Miscellaneous\Emojis */ |
|
| 20 | - protected $emojis; |
|
| 21 | - |
|
| 22 | - /** @var Miscellaneous\Gitignore */ |
|
| 23 | - protected $gitIgnore; |
|
| 24 | - |
|
| 25 | - /** @var Miscellaneous\Licenses */ |
|
| 26 | - protected $licenses; |
|
| 27 | - |
|
| 28 | - /** @var Miscellaneous\Markdown */ |
|
| 29 | - protected $markdown; |
|
| 30 | - |
|
| 31 | - /** @var Miscellaneous\Meta */ |
|
| 32 | - protected $meta; |
|
| 33 | - |
|
| 34 | - /** @var Miscellaneous\RateLimit */ |
|
| 35 | - protected $rateLimit; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * MiscellaneousTest constructor. |
|
| 39 | - * |
|
| 40 | - * @param null $name |
|
| 41 | - * @param array $data |
|
| 42 | - * @param string $dataName |
|
| 43 | - */ |
|
| 44 | - public function __construct($name = null, array $data = [], $dataName = '') |
|
| 45 | - { |
|
| 46 | - parent::__construct($name, $data, $dataName); |
|
| 47 | - |
|
| 48 | - // Miscellaneous |
|
| 49 | - $this->miscellaneous = $this->client->getReceiver(Client::MISCELLANEOUS); |
|
| 50 | - |
|
| 51 | - // Emojis |
|
| 52 | - $this->emojis = $this->miscellaneous->getReceiver(Miscellaneous::EMOJIS); |
|
| 53 | - |
|
| 54 | - // GitIgnore |
|
| 55 | - $this->gitIgnore = $this->miscellaneous->getReceiver(Miscellaneous::GITIGNORE); |
|
| 56 | - |
|
| 57 | - // Licenses |
|
| 58 | - $this->licenses = $this->miscellaneous->getReceiver(Miscellaneous::LICENSES); |
|
| 59 | - |
|
| 60 | - // Markdown |
|
| 61 | - $this->markdown = $this->miscellaneous->getReceiver(Miscellaneous::MARKDOWN); |
|
| 62 | - |
|
| 63 | - // Meta |
|
| 64 | - $this->meta = $this->miscellaneous->getReceiver(Miscellaneous::META); |
|
| 65 | - |
|
| 66 | - // RateLimit |
|
| 67 | - $this->rateLimit = $this->miscellaneous->getReceiver(Miscellaneous::RATE_LIMIT); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Test list available Emojis |
|
| 72 | - */ |
|
| 73 | - public function testGetListEmojis() |
|
| 74 | - { |
|
| 75 | - $this->assertCount(1508, $this->emojis->get()); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * Test listing available templates |
|
| 80 | - */ |
|
| 81 | - public function testListingAvailableTemplates() |
|
| 82 | - { |
|
| 83 | - $templates = $this->gitIgnore->listingAvailableTemplates(); |
|
| 84 | - |
|
| 85 | - $this->assertContains('Android', $templates); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Test getting a single template |
|
| 90 | - */ |
|
| 91 | - public function testGetSingleTemplate() |
|
| 92 | - { |
|
| 93 | - $template = $this->gitIgnore->getSingleTemplate('Android'); |
|
| 94 | - |
|
| 95 | - $this->assertArrayHasKey('name', $template); |
|
| 96 | - $this->assertArrayHasKey('source', $template); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * Test listing all licenses |
|
| 101 | - */ |
|
| 102 | - public function testListAllLicenses() |
|
| 103 | - { |
|
| 104 | - $licenses = $this->licenses->listAllLicenses(); |
|
| 105 | - $license = array_pop($licenses); |
|
| 106 | - |
|
| 107 | - $this->assertArrayHasKey('key', $license); |
|
| 108 | - $this->assertArrayHasKey('name', $license); |
|
| 109 | - $this->assertArrayHasKey('spdx_id', $license); |
|
| 110 | - $this->assertArrayHasKey('url', $license); |
|
| 111 | - $this->assertArrayHasKey('featured', $license); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * Test getting individual license |
|
| 116 | - */ |
|
| 117 | - public function testGettingIndividualLicense() |
|
| 118 | - { |
|
| 119 | - $license = $this->licenses->getIndividualLicense('mit'); |
|
| 120 | - |
|
| 121 | - $this->assertArrayHasKey('body', $license); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * Test render markdown text |
|
| 126 | - */ |
|
| 127 | - public function testRender() |
|
| 128 | - { |
|
| 129 | - $output = $this->markdown->render('Hello world FlexyProject/GitHubAPI#43 **cool**, and #43!'); |
|
| 130 | - |
|
| 131 | - $this->assertEquals('<p>Hello world FlexyProject/GitHubAPI#43 <strong>cool</strong>, and #43!</p>', |
|
| 132 | - str_replace(["\r\n", "\r", "\n"], "", $output[0])); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Test render markdown raw text |
|
| 137 | - */ |
|
| 138 | - public function testRenderRaw() |
|
| 139 | - { |
|
| 140 | - $output = $this->markdown->renderRaw('**cool**'); |
|
| 141 | - |
|
| 142 | - $this->assertEquals('<p>{"file":"<strong>cool</strong>"}</p>', |
|
| 143 | - str_replace(["\r\n", "\r", "\n"], "", $output[0])); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * Test getting meta about GitHub.com |
|
| 148 | - */ |
|
| 149 | - public function testGetMeta() |
|
| 150 | - { |
|
| 151 | - $meta = $this->meta->get(); |
|
| 152 | - |
|
| 153 | - $this->assertTrue($meta['verifiable_password_authentication']); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * Test rate limit |
|
| 158 | - */ |
|
| 159 | - public function testRateLimit() |
|
| 160 | - { |
|
| 161 | - $rateLimit = $this->rateLimit->get(); |
|
| 162 | - |
|
| 163 | - $this->assertArrayHasKey('rate', $rateLimit); |
|
| 164 | - } |
|
| 16 | + /** @var Miscellaneous */ |
|
| 17 | + protected $miscellaneous; |
|
| 18 | + |
|
| 19 | + /** @var Miscellaneous\Emojis */ |
|
| 20 | + protected $emojis; |
|
| 21 | + |
|
| 22 | + /** @var Miscellaneous\Gitignore */ |
|
| 23 | + protected $gitIgnore; |
|
| 24 | + |
|
| 25 | + /** @var Miscellaneous\Licenses */ |
|
| 26 | + protected $licenses; |
|
| 27 | + |
|
| 28 | + /** @var Miscellaneous\Markdown */ |
|
| 29 | + protected $markdown; |
|
| 30 | + |
|
| 31 | + /** @var Miscellaneous\Meta */ |
|
| 32 | + protected $meta; |
|
| 33 | + |
|
| 34 | + /** @var Miscellaneous\RateLimit */ |
|
| 35 | + protected $rateLimit; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * MiscellaneousTest constructor. |
|
| 39 | + * |
|
| 40 | + * @param null $name |
|
| 41 | + * @param array $data |
|
| 42 | + * @param string $dataName |
|
| 43 | + */ |
|
| 44 | + public function __construct($name = null, array $data = [], $dataName = '') |
|
| 45 | + { |
|
| 46 | + parent::__construct($name, $data, $dataName); |
|
| 47 | + |
|
| 48 | + // Miscellaneous |
|
| 49 | + $this->miscellaneous = $this->client->getReceiver(Client::MISCELLANEOUS); |
|
| 50 | + |
|
| 51 | + // Emojis |
|
| 52 | + $this->emojis = $this->miscellaneous->getReceiver(Miscellaneous::EMOJIS); |
|
| 53 | + |
|
| 54 | + // GitIgnore |
|
| 55 | + $this->gitIgnore = $this->miscellaneous->getReceiver(Miscellaneous::GITIGNORE); |
|
| 56 | + |
|
| 57 | + // Licenses |
|
| 58 | + $this->licenses = $this->miscellaneous->getReceiver(Miscellaneous::LICENSES); |
|
| 59 | + |
|
| 60 | + // Markdown |
|
| 61 | + $this->markdown = $this->miscellaneous->getReceiver(Miscellaneous::MARKDOWN); |
|
| 62 | + |
|
| 63 | + // Meta |
|
| 64 | + $this->meta = $this->miscellaneous->getReceiver(Miscellaneous::META); |
|
| 65 | + |
|
| 66 | + // RateLimit |
|
| 67 | + $this->rateLimit = $this->miscellaneous->getReceiver(Miscellaneous::RATE_LIMIT); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * Test list available Emojis |
|
| 72 | + */ |
|
| 73 | + public function testGetListEmojis() |
|
| 74 | + { |
|
| 75 | + $this->assertCount(1508, $this->emojis->get()); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * Test listing available templates |
|
| 80 | + */ |
|
| 81 | + public function testListingAvailableTemplates() |
|
| 82 | + { |
|
| 83 | + $templates = $this->gitIgnore->listingAvailableTemplates(); |
|
| 84 | + |
|
| 85 | + $this->assertContains('Android', $templates); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Test getting a single template |
|
| 90 | + */ |
|
| 91 | + public function testGetSingleTemplate() |
|
| 92 | + { |
|
| 93 | + $template = $this->gitIgnore->getSingleTemplate('Android'); |
|
| 94 | + |
|
| 95 | + $this->assertArrayHasKey('name', $template); |
|
| 96 | + $this->assertArrayHasKey('source', $template); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * Test listing all licenses |
|
| 101 | + */ |
|
| 102 | + public function testListAllLicenses() |
|
| 103 | + { |
|
| 104 | + $licenses = $this->licenses->listAllLicenses(); |
|
| 105 | + $license = array_pop($licenses); |
|
| 106 | + |
|
| 107 | + $this->assertArrayHasKey('key', $license); |
|
| 108 | + $this->assertArrayHasKey('name', $license); |
|
| 109 | + $this->assertArrayHasKey('spdx_id', $license); |
|
| 110 | + $this->assertArrayHasKey('url', $license); |
|
| 111 | + $this->assertArrayHasKey('featured', $license); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * Test getting individual license |
|
| 116 | + */ |
|
| 117 | + public function testGettingIndividualLicense() |
|
| 118 | + { |
|
| 119 | + $license = $this->licenses->getIndividualLicense('mit'); |
|
| 120 | + |
|
| 121 | + $this->assertArrayHasKey('body', $license); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Test render markdown text |
|
| 126 | + */ |
|
| 127 | + public function testRender() |
|
| 128 | + { |
|
| 129 | + $output = $this->markdown->render('Hello world FlexyProject/GitHubAPI#43 **cool**, and #43!'); |
|
| 130 | + |
|
| 131 | + $this->assertEquals('<p>Hello world FlexyProject/GitHubAPI#43 <strong>cool</strong>, and #43!</p>', |
|
| 132 | + str_replace(["\r\n", "\r", "\n"], "", $output[0])); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Test render markdown raw text |
|
| 137 | + */ |
|
| 138 | + public function testRenderRaw() |
|
| 139 | + { |
|
| 140 | + $output = $this->markdown->renderRaw('**cool**'); |
|
| 141 | + |
|
| 142 | + $this->assertEquals('<p>{"file":"<strong>cool</strong>"}</p>', |
|
| 143 | + str_replace(["\r\n", "\r", "\n"], "", $output[0])); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * Test getting meta about GitHub.com |
|
| 148 | + */ |
|
| 149 | + public function testGetMeta() |
|
| 150 | + { |
|
| 151 | + $meta = $this->meta->get(); |
|
| 152 | + |
|
| 153 | + $this->assertTrue($meta['verifiable_password_authentication']); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * Test rate limit |
|
| 158 | + */ |
|
| 159 | + public function testRateLimit() |
|
| 160 | + { |
|
| 161 | + $rateLimit = $this->rateLimit->get(); |
|
| 162 | + |
|
| 163 | + $this->assertArrayHasKey('rate', $rateLimit); |
|
| 164 | + } |
|
| 165 | 165 | } |
| 166 | 166 | \ No newline at end of file |
@@ -11,24 +11,24 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | abstract class AbstractTest extends TestCase |
| 13 | 13 | { |
| 14 | - /** @var Client */ |
|
| 15 | - protected $client; |
|
| 14 | + /** @var Client */ |
|
| 15 | + protected $client; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * AbstractTest constructor. |
|
| 19 | - * |
|
| 20 | - * @param null $name |
|
| 21 | - * @param array $data |
|
| 22 | - * @param string $dataName |
|
| 23 | - */ |
|
| 24 | - public function __construct($name = null, array $data = [], $dataName = '') |
|
| 25 | - { |
|
| 26 | - // Create a client object |
|
| 27 | - $this->client = new Client(); |
|
| 17 | + /** |
|
| 18 | + * AbstractTest constructor. |
|
| 19 | + * |
|
| 20 | + * @param null $name |
|
| 21 | + * @param array $data |
|
| 22 | + * @param string $dataName |
|
| 23 | + */ |
|
| 24 | + public function __construct($name = null, array $data = [], $dataName = '') |
|
| 25 | + { |
|
| 26 | + // Create a client object |
|
| 27 | + $this->client = new Client(); |
|
| 28 | 28 | |
| 29 | - // Set auth credentials |
|
| 30 | - $this->client->setHttpAuth($GLOBALS['USERNAME'], $GLOBALS['PASSWORD']); |
|
| 29 | + // Set auth credentials |
|
| 30 | + $this->client->setHttpAuth($GLOBALS['USERNAME'], $GLOBALS['PASSWORD']); |
|
| 31 | 31 | |
| 32 | - parent::__construct($name, $data, $dataName); |
|
| 33 | - } |
|
| 32 | + parent::__construct($name, $data, $dataName); |
|
| 33 | + } |
|
| 34 | 34 | } |
| 35 | 35 | \ No newline at end of file |