Skip to content

Commit b5d61c3

Browse files
committed
Add docblocks for git data
1 parent 9010dbe commit b5d61c3

File tree

5 files changed

+166
-0
lines changed

5 files changed

+166
-0
lines changed

lib/Github/Api/GitData/Blobs.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
*/
1212
class Blobs extends AbstractApi
1313
{
14+
/**
15+
* Configure the Acccept header depending on the blob type.
16+
*
17+
* @param string|null $bodyType
18+
*/
1419
public function configure($bodyType = null)
1520
{
1621
if ('raw' == $bodyType) {
@@ -20,13 +25,33 @@ public function configure($bodyType = null)
2025
}
2126
}
2227

28+
/**
29+
* Show a blob of a sha for a repository.
30+
*
31+
* @param string $username
32+
* @param string $repository
33+
* @param string $sha
34+
*
35+
* @return array
36+
*/
2337
public function show($username, $repository, $sha)
2438
{
2539
$response = $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/blobs/'.rawurlencode($sha));
2640

2741
return $response;
2842
}
2943

44+
/**
45+
* Create a blob of a sha for a repository.
46+
*
47+
* @param string $username
48+
* @param string $repository
49+
* @param array $params
50+
*
51+
* @return array
52+
*
53+
* @throws \Github\Exception\MissingArgumentException
54+
*/
3055
public function create($username, $repository, array $params)
3156
{
3257
if (!isset($params['content'], $params['encoding'])) {

lib/Github/Api/GitData/Commits.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,31 @@
1111
*/
1212
class Commits extends AbstractApi
1313
{
14+
/**
15+
* Show a commit for a repository.
16+
*
17+
* @param string $username
18+
* @param string $repository
19+
* @param string $sha
20+
*
21+
* @return array
22+
*/
1423
public function show($username, $repository, $sha)
1524
{
1625
return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/commits/'.rawurlencode($sha));
1726
}
1827

28+
/**
29+
* Create a commit for a repository.
30+
*
31+
* @param string $username
32+
* @param string $repository
33+
* @param array $params
34+
*
35+
* @return array
36+
*
37+
* @throws \Github\Exception\MissingArgumentException
38+
*/
1939
public function create($username, $repository, array $params)
2040
{
2141
if (!isset($params['message'], $params['tree'], $params['parents'])) {

lib/Github/Api/GitData/References.php

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,72 @@
1111
*/
1212
class References extends AbstractApi
1313
{
14+
/**
15+
* Get all references of a repository.
16+
*
17+
* @param string $username
18+
* @param string $repository
19+
*
20+
* @return array
21+
*/
1422
public function all($username, $repository)
1523
{
1624
return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs');
1725
}
1826

27+
/**
28+
* Get all branches of a repository.
29+
*
30+
* @param string $username
31+
* @param string $repository
32+
*
33+
* @return array
34+
*/
1935
public function branches($username, $repository)
2036
{
2137
return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs/heads');
2238
}
2339

40+
/**
41+
* Get all tags of a repository.
42+
*
43+
* @param string $username
44+
* @param string $repository
45+
*
46+
* @return array
47+
*/
2448
public function tags($username, $repository)
2549
{
2650
return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs/tags');
2751
}
2852

53+
/**
54+
* Show the reference of a repository.
55+
*
56+
* @param string $username
57+
* @param string $repository
58+
* @param string $reference
59+
*
60+
* @return array
61+
*/
2962
public function show($username, $repository, $reference)
3063
{
3164
$reference = $this->encodeReference($reference);
3265

3366
return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs/'.$reference);
3467
}
3568

69+
/**
70+
* Create a reference for a repository.
71+
*
72+
* @param string $username
73+
* @param string $repository
74+
* @param array $params
75+
*
76+
* @return array
77+
*
78+
* @throws \Github\Exception\MissingArgumentException
79+
*/
3680
public function create($username, $repository, array $params)
3781
{
3882
if (!isset($params['ref'], $params['sha'])) {
@@ -42,6 +86,18 @@ public function create($username, $repository, array $params)
4286
return $this->post('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs', $params);
4387
}
4488

89+
/**
90+
* Update a reference for a repository.
91+
*
92+
* @param string $username
93+
* @param string $repository
94+
* @param string $reference
95+
* @param array $params
96+
*
97+
* @return array
98+
*
99+
* @throws \Github\Exception\MissingArgumentException
100+
*/
45101
public function update($username, $repository, $reference, array $params)
46102
{
47103
if (!isset($params['sha'])) {
@@ -53,13 +109,29 @@ public function update($username, $repository, $reference, array $params)
53109
return $this->patch('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs/'.$reference, $params);
54110
}
55111

112+
/**
113+
* Delete a reference of a repository.
114+
*
115+
* @param string $username
116+
* @param string $repository
117+
* @param string $reference
118+
*
119+
* @return array
120+
*/
56121
public function remove($username, $repository, $reference)
57122
{
58123
$reference = $this->encodeReference($reference);
59124

60125
return $this->delete('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs/'.$reference);
61126
}
62127

128+
/**
129+
* Encode the raw reference.
130+
*
131+
* @param string $rawReference
132+
*
133+
* @return string
134+
*/
63135
private function encodeReference($rawReference)
64136
{
65137
return implode('/', array_map('rawurlencode', explode('/', $rawReference)));

lib/Github/Api/GitData/Tags.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,44 @@
1111
*/
1212
class Tags extends AbstractApi
1313
{
14+
/**
15+
* Get all tags for a repository.
16+
*
17+
* @param string $username
18+
* @param string $repository
19+
*
20+
* @return array
21+
*/
1422
public function all($username, $repository)
1523
{
1624
return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs/tags');
1725
}
1826

27+
/**
28+
* Get a tag for a repository.
29+
*
30+
* @param string $username
31+
* @param string $repository
32+
* @param string $sha
33+
*
34+
* @return array
35+
*/
1936
public function show($username, $repository, $sha)
2037
{
2138
return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/tags/'.rawurlencode($sha));
2239
}
2340

41+
/**
42+
* Create a tag for a repository.
43+
*
44+
* @param string $username
45+
* @param string $repository
46+
* @param array $params
47+
*
48+
* @return array
49+
*
50+
* @throws \Github\Exception\MissingArgumentException
51+
*/
2452
public function create($username, $repository, array $params)
2553
{
2654
if (!isset($params['tag'], $params['message'], $params['object'], $params['type'])) {

lib/Github/Api/GitData/Trees.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,32 @@
1111
*/
1212
class Trees extends AbstractApi
1313
{
14+
/**
15+
* Get the tree for a repository.
16+
*
17+
* @param string $username
18+
* @param string $repository
19+
* @param string $sha
20+
* @param bool $recursive
21+
*
22+
* @return array
23+
*/
1424
public function show($username, $repository, $sha, $recursive = false)
1525
{
1626
return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/trees/'.rawurlencode($sha), array('recursive' => $recursive ? 1 : null));
1727
}
1828

29+
/**
30+
* Create tree for a repository.
31+
*
32+
* @param string $username
33+
* @param string $repository
34+
* @param array $params
35+
*
36+
* @return array
37+
*
38+
* @throws \Github\Exception\MissingArgumentException
39+
*/
1940
public function create($username, $repository, array $params)
2041
{
2142
if (!isset($params['tree']) || !is_array($params['tree'])) {

0 commit comments

Comments
 (0)