This repository has been archived by the owner on Feb 1, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
completed v2.0 : complete rewrite of code, docs and tests. BC compati…
…bility preserved.
- Loading branch information
Showing
15 changed files
with
569 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
/** | ||
* Abstract class for phpGitHubApi classes | ||
* | ||
* @author Thibault Duplessis <thibault.duplessis at gmail dot com> | ||
* @license MIT License | ||
*/ | ||
abstract class phpGitHubApiAbstract | ||
{ | ||
protected $api; | ||
|
||
public function __construct(phpGitHubApi $api) | ||
{ | ||
$this->api = $api; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
require_once(dirname(__FILE__).'/phpGitHubApiAbstract.php'); | ||
|
||
/** | ||
* Getting information on specific commits, the diffs they introduce, the files they've changed. | ||
* | ||
* @author Thibault Duplessis <thibault.duplessis at gmail dot com> | ||
* @license MIT License | ||
*/ | ||
class phpGitHubApiCommit extends phpGitHubApiAbstract | ||
{ | ||
|
||
/** | ||
* List commits by username, repo and branch | ||
* http://develop.github.com/p/commits.html#listing_commits_on_a_branch | ||
* | ||
* @param string $username the username | ||
* @param string $repo the repo | ||
* @param string $branch the branch | ||
* @return array list of users found | ||
*/ | ||
public function getBranchCommits($username, $repo, $branch) | ||
{ | ||
$response = $this->api->get('commits/list/'.$username.'/'.$repo.'/'.$branch); | ||
|
||
return $response['commits']; | ||
} | ||
|
||
/** | ||
* List commits by username, repo, branch and path | ||
* http://develop.github.com/p/commits.html#listing_commits_for_a_file | ||
* | ||
* @param string $username the username | ||
* @param string $repo the repo | ||
* @param string $branch the branch | ||
* @param string $path the path | ||
* @return array list of users found | ||
*/ | ||
public function getFileCommits($username, $repo, $branch, $path) | ||
{ | ||
$response = $this->api->get('commits/list/'.$username.'/'.$repo.'/'.$branch.'/'.$path); | ||
|
||
return $response['commits']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
require_once(dirname(__FILE__).'/phpGitHubApiAbstract.php'); | ||
|
||
/** | ||
* Listing issues, searching, editing and closing your projects issues. | ||
* | ||
* @author Thibault Duplessis <thibault.duplessis at gmail dot com> | ||
* @license MIT License | ||
*/ | ||
class phpGitHubApiIssue extends phpGitHubApiAbstract | ||
{ | ||
|
||
/** | ||
* List issues by username, repo and state | ||
* http://develop.github.com/p/issues.html#list_a_projects_issues | ||
* | ||
* @param string $username the username | ||
* @param string $repo the repo | ||
* @param string $state the issue state, can be open or closed | ||
* @return array list of users found | ||
*/ | ||
public function getList($username, $repo, $state = 'open') | ||
{ | ||
$response = $this->api->get('issues/list/'.$username.'/'.$repo.'/'.$state); | ||
|
||
return $response['issues']; | ||
} | ||
|
||
/** | ||
* Search issues by username, repo, state and search term | ||
* http://develop.github.com/p/issues.html#list_a_projects_issues | ||
* | ||
* @param string $username the username | ||
* @param string $repo the repo | ||
* @param string $state the issue state, can be open or closed | ||
* @param string $searchTerm the search term to filter issues by | ||
* @return array list of users found | ||
*/ | ||
public function search($username, $repo, $state, $searchTerm) | ||
{ | ||
$response = $this->api->get('issues/search/'.$username.'/'.$repo.'/'.$state.'/'.$searchTerm); | ||
|
||
return $response['issues']; | ||
} | ||
|
||
/** | ||
* Get extended information about an issue by its username, repo and number | ||
* http://develop.github.com/p/issues.html#view_an_issue | ||
* | ||
* @param string $username the username | ||
* @param string $repo the repo | ||
* @param string $number the issue number | ||
* @return array informations about the issue | ||
*/ | ||
public function show($username, $repo, $number) | ||
{ | ||
$response = $this->api->get('issues/show/'.$username.'/'.$repo.'/'.$number); | ||
|
||
return $response['issue']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
require_once(dirname(__FILE__).'/phpGitHubApiAbstract.php'); | ||
|
||
/** | ||
* Getting full versions of specific files and trees in your Git repositories. | ||
* | ||
* @author Thibault Duplessis <thibault.duplessis at gmail dot com> | ||
* @license MIT License | ||
*/ | ||
class phpGitHubApiObject extends phpGitHubApiAbstract | ||
{ | ||
|
||
/** | ||
* Get a listing of the root tree of a project by the username, repo, and tree SHA | ||
* http://develop.github.com/p/object.html#trees | ||
* | ||
* @param string $username the username | ||
* @param string $repo the repo | ||
* @param string $treeSHA the tree sha | ||
* @return array root tree of the project | ||
*/ | ||
public function showTree($username, $repo, $treeSHA) | ||
{ | ||
$response = $this->api->get('tree/show/'.$username.'/'.$repo.'/'.$treeSHA); | ||
|
||
return $response['tree']; | ||
} | ||
|
||
/** | ||
* Get the data about a blob by tree SHA and file path. | ||
* http://develop.github.com/p/object.html#blobs | ||
* | ||
* @param string $username the username | ||
* @param string $repo the repo | ||
* @param string $treeSHA the tree sha | ||
* @param string $path the path | ||
* @return array data blob of tree and path | ||
*/ | ||
public function showBlob($username, $repo, $treeSHA, $path) | ||
{ | ||
$response = $this->api->get('blob/show/'.$username.'/'.$repo.'/'.$treeSHA .'/'.$path); | ||
|
||
return $response['blob']; | ||
} | ||
|
||
/** | ||
* Lists the data blobs of a tree by tree SHA | ||
* http://develop.github.com/p/object.html#blobs | ||
* | ||
* @param string $username the username | ||
* @param string $repo the repo | ||
* @param string $treeSHA the tree sha | ||
* @param string $path the path | ||
* @return array data blobs of tree | ||
*/ | ||
public function listBlobs($username, $repo, $treeSHA) | ||
{ | ||
$response = $this->api->get('blob/all/'.$username.'/'.$repo.'/'.$treeSHA); | ||
|
||
return $response['blobs']; | ||
} | ||
} |
Oops, something went wrong.