diff --git a/lib/Github/Api/GitData/Blobs.php b/lib/Github/Api/GitData/Blobs.php index 2ff844db24a..fe9cfc6123a 100644 --- a/lib/Github/Api/GitData/Blobs.php +++ b/lib/Github/Api/GitData/Blobs.php @@ -11,6 +11,11 @@ */ class Blobs extends AbstractApi { + /** + * Configure the Acccept header depending on the blob type. + * + * @param string|null $bodyType + */ public function configure($bodyType = null) { if ('raw' == $bodyType) { @@ -20,6 +25,15 @@ public function configure($bodyType = null) } } + /** + * Show a blob of a sha for a repository. + * + * @param string $username + * @param string $repository + * @param string $sha + * + * @return array + */ public function show($username, $repository, $sha) { $response = $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/blobs/'.rawurlencode($sha)); @@ -27,6 +41,17 @@ public function show($username, $repository, $sha) return $response; } + /** + * Create a blob of a sha for a repository. + * + * @param string $username + * @param string $repository + * @param array $params + * + * @return array + * + * @throws \Github\Exception\MissingArgumentException + */ public function create($username, $repository, array $params) { if (!isset($params['content'], $params['encoding'])) { diff --git a/lib/Github/Api/GitData/Commits.php b/lib/Github/Api/GitData/Commits.php index 1c161e1d790..f2f5d217cda 100644 --- a/lib/Github/Api/GitData/Commits.php +++ b/lib/Github/Api/GitData/Commits.php @@ -11,11 +11,31 @@ */ class Commits extends AbstractApi { + /** + * Show a commit for a repository. + * + * @param string $username + * @param string $repository + * @param string $sha + * + * @return array + */ public function show($username, $repository, $sha) { return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/commits/'.rawurlencode($sha)); } + /** + * Create a commit for a repository. + * + * @param string $username + * @param string $repository + * @param array $params + * + * @return array + * + * @throws \Github\Exception\MissingArgumentException + */ public function create($username, $repository, array $params) { if (!isset($params['message'], $params['tree'], $params['parents'])) { diff --git a/lib/Github/Api/GitData/References.php b/lib/Github/Api/GitData/References.php index 582900a57d5..3277b79e2b7 100644 --- a/lib/Github/Api/GitData/References.php +++ b/lib/Github/Api/GitData/References.php @@ -11,21 +11,54 @@ */ class References extends AbstractApi { + /** + * Get all references of a repository. + * + * @param string $username + * @param string $repository + * + * @return array + */ public function all($username, $repository) { return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs'); } + /** + * Get all branches of a repository. + * + * @param string $username + * @param string $repository + * + * @return array + */ public function branches($username, $repository) { return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs/heads'); } + /** + * Get all tags of a repository. + * + * @param string $username + * @param string $repository + * + * @return array + */ public function tags($username, $repository) { return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs/tags'); } + /** + * Show the reference of a repository. + * + * @param string $username + * @param string $repository + * @param string $reference + * + * @return array + */ public function show($username, $repository, $reference) { $reference = $this->encodeReference($reference); @@ -33,6 +66,17 @@ public function show($username, $repository, $reference) return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs/'.$reference); } + /** + * Create a reference for a repository. + * + * @param string $username + * @param string $repository + * @param array $params + * + * @return array + * + * @throws \Github\Exception\MissingArgumentException + */ public function create($username, $repository, array $params) { if (!isset($params['ref'], $params['sha'])) { @@ -42,6 +86,18 @@ public function create($username, $repository, array $params) return $this->post('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs', $params); } + /** + * Update a reference for a repository. + * + * @param string $username + * @param string $repository + * @param string $reference + * @param array $params + * + * @return array + * + * @throws \Github\Exception\MissingArgumentException + */ public function update($username, $repository, $reference, array $params) { if (!isset($params['sha'])) { @@ -53,6 +109,15 @@ public function update($username, $repository, $reference, array $params) return $this->patch('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs/'.$reference, $params); } + /** + * Delete a reference of a repository. + * + * @param string $username + * @param string $repository + * @param string $reference + * + * @return array + */ public function remove($username, $repository, $reference) { $reference = $this->encodeReference($reference); @@ -60,6 +125,13 @@ public function remove($username, $repository, $reference) return $this->delete('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs/'.$reference); } + /** + * Encode the raw reference. + * + * @param string $rawReference + * + * @return string + */ private function encodeReference($rawReference) { return implode('/', array_map('rawurlencode', explode('/', $rawReference))); diff --git a/lib/Github/Api/GitData/Tags.php b/lib/Github/Api/GitData/Tags.php index b27dddd12f4..4b2d0341ef3 100644 --- a/lib/Github/Api/GitData/Tags.php +++ b/lib/Github/Api/GitData/Tags.php @@ -11,16 +11,44 @@ */ class Tags extends AbstractApi { + /** + * Get all tags for a repository. + * + * @param string $username + * @param string $repository + * + * @return array + */ public function all($username, $repository) { return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs/tags'); } + /** + * Get a tag for a repository. + * + * @param string $username + * @param string $repository + * @param string $sha + * + * @return array + */ public function show($username, $repository, $sha) { return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/tags/'.rawurlencode($sha)); } + /** + * Create a tag for a repository. + * + * @param string $username + * @param string $repository + * @param array $params + * + * @return array + * + * @throws \Github\Exception\MissingArgumentException + */ public function create($username, $repository, array $params) { if (!isset($params['tag'], $params['message'], $params['object'], $params['type'])) { diff --git a/lib/Github/Api/GitData/Trees.php b/lib/Github/Api/GitData/Trees.php index 92bd21ac433..3ce35a476ac 100644 --- a/lib/Github/Api/GitData/Trees.php +++ b/lib/Github/Api/GitData/Trees.php @@ -11,11 +11,32 @@ */ class Trees extends AbstractApi { + /** + * Get the tree for a repository. + * + * @param string $username + * @param string $repository + * @param string $sha + * @param bool $recursive + * + * @return array + */ public function show($username, $repository, $sha, $recursive = false) { return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/trees/'.rawurlencode($sha), array('recursive' => $recursive ? 1 : null)); } + /** + * Create tree for a repository. + * + * @param string $username + * @param string $repository + * @param array $params + * + * @return array + * + * @throws \Github\Exception\MissingArgumentException + */ public function create($username, $repository, array $params) { if (!isset($params['tree']) || !is_array($params['tree'])) {