Repository navigation
Expand file tree
/
Copy pathContents.php
More file actions
75 lines (68 loc) · 2.59 KB
/
Copy pathContents.php
File metadata and controls
75 lines (68 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
namespace Github\Api\Repository;
use Github\Api\AbstractApi;
use Github\Exception\MissingArgumentException;
/**
* @link http://developer.github.com/v3/repos/contents/
* @author Joseph Bielawski <stloyd@gmail.com>
*/
class Contents extends AbstractApi
{
/**
* Get content of README file in a repository
* @link http://developer.github.com/v3/repos/contents/
*
* @param string $username the user who owns the repository
* @param string $repository the name of the repository
* @param string $reference reference to a branch or commit
*
* @return array information for README file
*/
public function readme($username, $repository, $reference = null)
{
return $this->get('repos/'.urlencode($username).'/'.urlencode($repository).'/readme', array(
'ref' => $reference
));
}
/**
* Get contents of any file or directory in a repository
* @link http://developer.github.com/v3/repos/contents/
*
* @param string $username the user who owns the repository
* @param string $repository the name of the repository
* @param string $path path to file or directory
* @param string $reference reference to a branch or commit
*
* @return array information for file | information for each item in directory
*/
public function show($username, $repository, $path = null, $reference = null)
{
$url = 'repos/'.urlencode($username).'/'.urlencode($repository).'/contents';
if (null !== $path) {
$url .= '/'.urlencode($path);
}
return $this->get($url, array(
'ref' => $reference
));
}
/**
* Get content of archives in a repository
* @link http://developer.github.com/v3/repos/contents/
*
* @param string $username the user who owns the repository
* @param string $repository the name of the repository
* @param string $format format of archive: tarball or zipball
* @param string $reference reference to a branch or commit
*
* @return array information for archives
*/
public function archive($username, $repository, $format, $reference = null)
{
if (!in_array($format, array('tarball', 'zipball'))) {
$format = 'tarball';
}
return $this->get('repos/'.urlencode($username).'/'.urlencode($repository).'/'.urlencode($format), array(
'ref' => $reference
));
}
}