PHP Interface Gush\Adapter\Adapter

Note that each adapter instance can be only used for one repository.
Show file Open project: gushphp/gush Interface Usage Examples

Public Methods

Method Description
authenticate ( ) : boolean Authenticates the Adapter.
closePullRequest ( integer $id ) Close a pull-request by id.
createComment ( integer $id, string $message ) : string | null Creates a new a comment on an issue/pull-request.
createFork ( string $org ) : array Creates a fork from upstream and returns an array with the forked url.
createRelease ( string $name, array $parameters = [] ) : array Creates a new release.
createReleaseAssets ( integer $id, string $name, string $contentType, string $content ) : integer Creates a new release asset.
createRepo ( string $name, string $description, string $homepage, boolean $public = true, null $organization = null, boolean $hasIssues = true, boolean $hasWiki = false, boolean $hasDownloads = false, integer $teamId, boolean $autoInit = true ) : array
getComments ( integer $id ) : array[] Gets comments of a pull-request.
getLabels ( ) : string[] Gets the supported labels.
getMilestones ( array $parameters = [] ) : string[] Gets the supported milestones.
getPullRequest ( integer $id ) : array Gets the information of a pull-request by id.
getPullRequestCommits ( integer $id ) : array[] Gets the version-commits of a pull-request.
getPullRequestStates ( ) : string[] Gets the supported pull-request states.
getPullRequests ( string $state = null, integer $limit = 30 ) : array[] Gets the pull-requests.
getReleaseAssets ( integer $id ) : array[] Gets all available release assets of an release.
getReleases ( ) : array[] Gets all available created-releases.
getRepositoryInfo ( string $org, string $repository ) : array Gets the information from the requested repository.
isAuthenticated ( ) : boolean Returns true if the adapter is authenticated, false otherwise.
openPullRequest ( string $base, string $head, string $subject, string $body, array $parameters = [] ) : array Opens a new pull-request.
removeRelease ( integer $id ) Deletes a release.
supportsRepository ( string $remoteUrl ) : boolean Returns whether the repository is supported by this adapter.
switchPullRequestBase ( integer $prNumber, string $newBase, string $newHead, boolean $forceNewPr = false ) : array Switches the pull-request base.
updatePullRequest ( integer $id, array $parameters ) Updates the state of a pull-request by id.

Method Details

authenticate() public method

Authenticates the Adapter.
public authenticate ( ) : boolean
return boolean

closePullRequest() public method

Close a pull-request by id.
public closePullRequest ( integer $id )
$id integer

createComment() public method

Creates a new a comment on an issue/pull-request.
public createComment ( integer $id, string $message ) : string | null
$id integer
$message string
return string | null URL to the comment ex. "https://github.com/octocat/Hello-World/pull/1347#issuecomment-1

createFork() public method

Creates a fork from upstream and returns an array with the forked url.
public createFork ( string $org ) : array
$org string Organisation name
return array An array the with following keys: git_url, html_url

createRelease() public method

For clarity, a release is a tagged version with additional information like a changelog.
public createRelease ( string $name, array $parameters = [] ) : array
$name string
$parameters array
return array Returns an array with url and id of the created release

createReleaseAssets() public method

An asset can be eg documentation or a full download (library package with vendors). Not every Hub provider supports this however, so implementation is optional.
public createReleaseAssets ( integer $id, string $name, string $contentType, string $content ) : integer
$id integer Id of the release (must exist)
$name string Name of the asset (including file extension)
$contentType string Mime-type of the asset
$content string Actual asset (in raw-binary form without conversion)
return integer returns the id of the asset

createRepo() public method

public createRepo ( string $name, string $description, string $homepage, boolean $public = true, null $organization = null, boolean $hasIssues = true, boolean $hasWiki = false, boolean $hasDownloads = false, integer $teamId, boolean $autoInit = true ) : array
$name string
$description string
$homepage string
$public boolean
$organization null
$hasIssues boolean
$hasWiki boolean
$hasDownloads boolean
$teamId integer
$autoInit boolean
return array

getComments() public method

. Returned value must be an array with the following data per entry (values are by example). If a value is not supported null must be used instead. "id": 1 "url": "https://github.com/octocat/Hello-World/pull/1347#issuecomment-1" "body": "Me too" "user": "username" "created_at": "DateTime Object" "updated_at": "DateTime Object"
public getComments ( integer $id ) : array[]
$id integer
return array[] [['id' => 1, ...]]

getLabels() public method

When the issue tracker does not support labels, this will return an empty array.
public getLabels ( ) : string[]
return string[]

getMilestones() public method

Gets the supported milestones.
public getMilestones ( array $parameters = [] ) : string[]
$parameters array
return string[]

getPullRequest() public method

Returned value must be an array with the following data (values are by example). If a value is not supported null must be used instead. "url": "https://github.com/octocat/Hello-World/pull/1" "number": 1 "state": "open" "title": "new-feature" "body": "Please pull these awesome changes" "labels": ["bug"] "milestone": "v1.0" "created_at": "DateTime Object" "updated_at": "DateTime Object" "user": "username" "assignee": "username" "merged": false "merged_by": "username" "head": [ "ref": "new-topic" "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e" "user": "username" "repo": "Hello-World" ] "base": [ "label": "master" "ref": "master" "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e" "user": "username" "repo": "Hello-World" ]
public getPullRequest ( integer $id ) : array
$id integer
return array

getPullRequestCommits() public method

Returned value must be an array with the following data per entry (values are by example). If a value is not supported null must be used instead. 'sha': '6dcb09b5b57875f334f61aebed695e2e4193db5e' 'message': 'Fix all the bugs' 'user': 'username'
public getPullRequestCommits ( integer $id ) : array[]
$id integer
return array[] [['sha1' => 'dcb09b5b57875f334f61aebed695e2e4193db5e', ...]]

getPullRequestStates() public method

Gets the supported pull-request states.
public getPullRequestStates ( ) : string[]
return string[]

getPullRequests() public method

Gets the pull-requests.
public getPullRequests ( string $state = null, integer $limit = 30 ) : array[]
$state string Only get pull-requests with this state (use getPullRequestStates() for supported states)
$limit integer
return array[] An array where each entry has the same structure as described in getPullRequest()

getReleaseAssets() public method

Returned value must be an array with the following data per entry (values are by example). If a value is not supported null must be used instead. Note. Size is in bytes, url contains a link to the asset. but may not necessarily download the actual asset. State can be: "uploaded", "empty", or "uploading". "url": "https://api.github.com/repos/octocat/Hello-World/releases/assets/1" "id": 1 "name": "example.zip" "label": "short description" "state": "uploaded" "content_type": "application/zip" "size": 1024 "created_at": "DateTime Object" "updated_at": "DateTime Object" "uploader": "username"
public getReleaseAssets ( integer $id ) : array[]
$id integer Id of the release (must exist)
return array[] [['id' => 1, ...]]

getReleases() public method

Returned value must be an array with the following data per entry (values are by example). If a value is not supported null must be used instead. "url": "https://github.com/octocat/Hello-World/releases/v1.0.0" "id": 1 "name": "v1.0.0" "tag_name": "v1.0.0" "body": "Description of the release" "draft": false "prerelease": false "created_at": "DateTime Object" "published_at": "DateTime Object" "user": "username"
public getReleases ( ) : array[]
return array[] [['id' => 1, ...]]

getRepositoryInfo() public method

Returned value must be an array with the following data (values are by example). If a value is not supported null must be used instead, or false in case of a boolean. "owner": "username" "html_url": "https://github.com/octocat/Hello-World" "fetch_url": "https://github.com/octocat/Hello-World.git" "push_url": "[email protected]:octocat/Hello-World.git" "is_fork": false "is_private": false "fork_origin": [ "org": null "repo": null ] fork_origin is used to find the original organization and repository. When this repository is the head-parent, "fork_origin" may be null.
public getRepositoryInfo ( string $org, string $repository ) : array
$org string
$repository string
return array

isAuthenticated() public method

Returns true if the adapter is authenticated, false otherwise.
public isAuthenticated ( ) : boolean
return boolean

openPullRequest() public method

Opens a new pull-request.
public openPullRequest ( string $base, string $head, string $subject, string $body, array $parameters = [] ) : array
$base string
$head string
$subject string
$body string
$parameters array
return array An array the with following keys: html_url, number

removeRelease() public method

Deletes a release.
public removeRelease ( integer $id )
$id integer

supportsRepository() public method

Returns whether the repository is supported by this adapter.
public supportsRepository ( string $remoteUrl ) : boolean
$remoteUrl string
return boolean

switchPullRequestBase() public method

When the adapter does not support changing the base-branch, a new PR should be opened with same subject, body and labels. And the old PR should be closed.
public switchPullRequestBase ( integer $prNumber, string $newBase, string $newHead, boolean $forceNewPr = false ) : array
$prNumber integer
$newBase string New base for the PR
$newHead string org:branch
$forceNewPr boolean Open new PR (even when switching is supported)
return array An array with the following keys: html_url, number (either the current or the new PR)

updatePullRequest() public method

Updates the state of a pull-request by id.
public updatePullRequest ( integer $id, array $parameters )
$id integer
$parameters array