1 | <?php |
||
14 | class GithubAdapter extends AbstractAdapter |
||
15 | { |
||
16 | use StreamedTrait; |
||
17 | |||
18 | const COMMITTER_MAIL = 'email'; |
||
19 | const COMMITTER_NAME = 'name'; |
||
20 | |||
21 | const VISIBILITY_PRIVATE = 'private'; |
||
22 | const VISIBILITY_PUBLIC = 'public'; |
||
23 | |||
24 | /** @var ApiInterface */ |
||
25 | private $api; |
||
26 | |||
27 | /** |
||
28 | * @return ApiInterface |
||
29 | */ |
||
30 | final public function getApi() |
||
34 | |||
35 | /** |
||
36 | * @param ApiInterface $api |
||
37 | */ |
||
38 | public function __construct(ApiInterface $api) |
||
42 | |||
43 | /** |
||
44 | * Write a new file. |
||
45 | * |
||
46 | * @param string $path |
||
47 | * @param string $contents |
||
48 | * @param Config $config Config object |
||
49 | * |
||
50 | * @return array|false false on failure file meta data on success |
||
51 | */ |
||
52 | public function write($path, $contents, Config $config) |
||
57 | |||
58 | /** |
||
59 | * Update a file. |
||
60 | * |
||
61 | * @param string $path |
||
62 | * @param string $contents |
||
63 | * @param Config $config Config object |
||
64 | * |
||
65 | * @return array|false false on failure file meta data on success |
||
66 | */ |
||
67 | public function update($path, $contents, Config $config) |
||
72 | |||
73 | /** |
||
74 | * Rename a file. |
||
75 | * |
||
76 | * @param string $path |
||
77 | * @param string $newpath |
||
78 | * |
||
79 | * @return bool |
||
80 | */ |
||
81 | public function rename($path, $newpath) |
||
86 | |||
87 | /** |
||
88 | * Copy a file. |
||
89 | * |
||
90 | * @param string $path |
||
91 | * @param string $newpath |
||
92 | * |
||
93 | * @return bool |
||
94 | */ |
||
95 | public function copy($path, $newpath) |
||
100 | |||
101 | /** |
||
102 | * Delete a file. |
||
103 | * |
||
104 | * @param string $path |
||
105 | * |
||
106 | * @return bool |
||
107 | */ |
||
108 | public function delete($path) |
||
113 | |||
114 | /** |
||
115 | * Delete a directory. |
||
116 | * |
||
117 | * @param string $dirname |
||
118 | * |
||
119 | * @return bool |
||
120 | */ |
||
121 | public function deleteDir($dirname) |
||
126 | |||
127 | /** |
||
128 | * Create a directory. |
||
129 | * |
||
130 | * @param string $dirname directory name |
||
131 | * @param Config $config |
||
132 | * |
||
133 | * @return array|false |
||
134 | */ |
||
135 | public function createDir($dirname, Config $config) |
||
140 | |||
141 | /** |
||
142 | * Set the visibility for a file. |
||
143 | * |
||
144 | * @param string $path |
||
145 | * @param string $visibility |
||
146 | * |
||
147 | * @return array|false file meta data |
||
|
|||
148 | */ |
||
149 | public function setVisibility($path, $visibility) |
||
153 | |||
154 | /** |
||
155 | * Check that a file or directory exists in the repository |
||
156 | * |
||
157 | * @param string $path |
||
158 | * |
||
159 | * @return array|bool|null |
||
160 | */ |
||
161 | public function has($path) |
||
165 | |||
166 | /** |
||
167 | * Read a file |
||
168 | * |
||
169 | * @param string $path |
||
170 | * |
||
171 | * @return array|false |
||
172 | * |
||
173 | * @throws \Github\Exception\ErrorException |
||
174 | */ |
||
175 | public function read($path) |
||
179 | |||
180 | /** |
||
181 | * List contents of a directory. |
||
182 | * |
||
183 | * @param string $path |
||
184 | * @param bool $recursive |
||
185 | * |
||
186 | * @return array |
||
187 | */ |
||
188 | public function listContents($path = '/', $recursive = false) |
||
198 | |||
199 | /** |
||
200 | * Get all the meta data of a file or directory. |
||
201 | * |
||
202 | * @param string $path |
||
203 | * |
||
204 | * @return array|false |
||
205 | */ |
||
206 | public function getMetadata($path) |
||
210 | |||
211 | /** |
||
212 | * Get all the meta data of a file or directory. |
||
213 | * |
||
214 | * @param string $path |
||
215 | * |
||
216 | * @return array|false |
||
217 | */ |
||
218 | public function getSize($path) |
||
222 | |||
223 | /** |
||
224 | * Get the mimetype of a file. |
||
225 | * |
||
226 | * @param string $path |
||
227 | * |
||
228 | * @return array|false |
||
229 | */ |
||
230 | public function getMimetype($path) |
||
234 | |||
235 | /** |
||
236 | * Get the timestamp of a file. |
||
237 | * |
||
238 | * @param string $path |
||
239 | * |
||
240 | * @return array|false |
||
241 | */ |
||
242 | public function getTimestamp($path) |
||
246 | |||
247 | /** |
||
248 | * Get the visibility of a file. |
||
249 | * |
||
250 | * @param string $path |
||
251 | * |
||
252 | * @return array|false |
||
253 | */ |
||
254 | public function getVisibility($path) |
||
260 | |||
261 | /** |
||
262 | * @param $contents |
||
263 | * @return bool |
||
264 | */ |
||
265 | private function isDirectoryContents($contents) |
||
277 | } |
||
278 | |||
280 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.