5
5
use Github \Api \AbstractApi ;
6
6
use Github \Exception \InvalidArgumentException ;
7
7
use Github \Exception \ErrorException ;
8
+ use Github \Exception \MissingArgumentException ;
8
9
9
10
/**
10
11
* @link http://developer.github.com/v3/repos/contents/
@@ -62,10 +63,13 @@ public function show($username, $repository, $path = null, $reference = null)
62
63
* @param string $content contents of the new file
63
64
* @param string $message the commit message
64
65
* @param null|string $branch name of a branch
66
+ * @param null|array $committer information about the committer
67
+ *
68
+ * @throws MissingArgumentException
65
69
*
66
70
* @return array information about the new file
67
71
*/
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 )
69
73
{
70
74
$ url = 'repos/ ' .rawurlencode ($ username ).'/ ' .rawurlencode ($ repository ).'/contents/ ' .rawurlencode ($ path );
71
75
@@ -78,6 +82,13 @@ public function create($username, $repository, $path, $content, $message, $branc
78
82
$ parameters ['branch ' ] = $ branch ;
79
83
}
80
84
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
+
81
92
return $ this ->put ($ url , $ parameters );
82
93
}
83
94
@@ -92,10 +103,13 @@ public function create($username, $repository, $path, $content, $message, $branc
92
103
* @param string $message the commit message
93
104
* @param string $sha blob SHA of the file being replaced
94
105
* @param null|string $branch name of a branch
106
+ * @param null|array $committer information about the committer
107
+ *
108
+ * @throws MissingArgumentException
95
109
*
96
110
* @return array information about the updated file
97
111
*/
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 )
99
113
{
100
114
$ url = 'repos/ ' .rawurlencode ($ username ).'/ ' .rawurlencode ($ repository ).'/contents/ ' .rawurlencode ($ path );
101
115
@@ -109,6 +123,13 @@ public function update($username, $repository, $path, $content, $message, $sha,
109
123
$ parameters ['branch ' ] = $ branch ;
110
124
}
111
125
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
+
112
133
return $ this ->put ($ url , $ parameters );
113
134
}
114
135
@@ -123,10 +144,13 @@ public function update($username, $repository, $path, $content, $message, $sha,
123
144
* @param string $message the commit message
124
145
* @param string $sha blob SHA of the file being deleted
125
146
* @param null|string $branch name of a branch
147
+ * @param null|array $committer information about the committer
148
+ *
149
+ * @throws MissingArgumentException
126
150
*
127
151
* @return array information about the updated file
128
152
*/
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 )
130
154
{
131
155
$ url = 'repos/ ' .rawurlencode ($ username ).'/ ' .rawurlencode ($ repository ).'/contents/ ' .rawurlencode ($ path );
132
156
@@ -139,6 +163,13 @@ public function rm($username, $repository, $path, $message, $sha, $branch = null
139
163
$ parameters ['branch ' ] = $ branch ;
140
164
}
141
165
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
+
142
173
return $ this ->delete ($ url , $ parameters );
143
174
}
144
175
0 commit comments