1111 */
1212class 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 )));
0 commit comments