55use Github \Api \AbstractApi ;
66use Github \Exception \InvalidArgumentException ;
77use Github \Exception \ErrorException ;
8+ use Github \Exception \MissingArgumentException ;
89
910/**
1011 * @link http://developer.github.com/v3/repos/contents/
@@ -62,10 +63,13 @@ public function show($username, $repository, $path = null, $reference = null)
6263 * @param string $content contents of the new file
6364 * @param string $message the commit message
6465 * @param null|string $branch name of a branch
66+ * @param null|array $committer information about the committer
67+ *
68+ * @throws MissingArgumentException
6569 *
6670 * @return array information about the new file
6771 */
68- public function create ($ username , $ repository , $ path , $ content , $ message , $ branch = null )
72+ public function create ($ username , $ repository , $ path , $ content , $ message , $ branch = null , array $ committer = null )
6973 {
7074 $ url = 'repos/ ' .rawurlencode ($ username ).'/ ' .rawurlencode ($ repository ).'/contents/ ' .rawurlencode ($ path );
7175
@@ -78,6 +82,13 @@ public function create($username, $repository, $path, $content, $message, $branc
7882 $ parameters ['branch ' ] = $ branch ;
7983 }
8084
85+ if (null !== $ committer ) {
86+ if (!isset ($ committer ['name ' ], $ committer ['email ' ])) {
87+ throw new MissingArgumentException (array ('name ' , 'email ' ));
88+ }
89+ $ parameters ['committer ' ] = $ committer ;
90+ }
91+
8192 return $ this ->put ($ url , $ parameters );
8293 }
8394
@@ -92,10 +103,13 @@ public function create($username, $repository, $path, $content, $message, $branc
92103 * @param string $message the commit message
93104 * @param string $sha blob SHA of the file being replaced
94105 * @param null|string $branch name of a branch
106+ * @param null|array $committer information about the committer
107+ *
108+ * @throws MissingArgumentException
95109 *
96110 * @return array information about the updated file
97111 */
98- public function update ($ username , $ repository , $ path , $ content , $ message , $ sha , $ branch = null )
112+ public function update ($ username , $ repository , $ path , $ content , $ message , $ sha , $ branch = null , array $ committer = null )
99113 {
100114 $ url = 'repos/ ' .rawurlencode ($ username ).'/ ' .rawurlencode ($ repository ).'/contents/ ' .rawurlencode ($ path );
101115
@@ -109,6 +123,13 @@ public function update($username, $repository, $path, $content, $message, $sha,
109123 $ parameters ['branch ' ] = $ branch ;
110124 }
111125
126+ if (null !== $ committer ) {
127+ if (!isset ($ committer ['name ' ], $ committer ['email ' ])) {
128+ throw new MissingArgumentException (array ('name ' , 'email ' ));
129+ }
130+ $ parameters ['committer ' ] = $ committer ;
131+ }
132+
112133 return $ this ->put ($ url , $ parameters );
113134 }
114135
@@ -123,10 +144,13 @@ public function update($username, $repository, $path, $content, $message, $sha,
123144 * @param string $message the commit message
124145 * @param string $sha blob SHA of the file being deleted
125146 * @param null|string $branch name of a branch
147+ * @param null|array $committer information about the committer
148+ *
149+ * @throws MissingArgumentException
126150 *
127151 * @return array information about the updated file
128152 */
129- public function rm ($ username , $ repository , $ path , $ message , $ sha , $ branch = null )
153+ public function rm ($ username , $ repository , $ path , $ message , $ sha , $ branch = null , array $ committer = null )
130154 {
131155 $ url = 'repos/ ' .rawurlencode ($ username ).'/ ' .rawurlencode ($ repository ).'/contents/ ' .rawurlencode ($ path );
132156
@@ -139,6 +163,13 @@ public function rm($username, $repository, $path, $message, $sha, $branch = null
139163 $ parameters ['branch ' ] = $ branch ;
140164 }
141165
166+ if (null !== $ committer ) {
167+ if (!isset ($ committer ['name ' ], $ committer ['email ' ])) {
168+ throw new MissingArgumentException (array ('name ' , 'email ' ));
169+ }
170+ $ parameters ['committer ' ] = $ committer ;
171+ }
172+
142173 return $ this ->delete ($ url , $ parameters );
143174 }
144175
0 commit comments