|
1
|
|
|
<?php |
|
2
|
|
|
namespace FlexyProject\GitHub\Receiver\Repositories; |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* The Statistics API class provides access to repository's statistics. |
|
6
|
|
|
* |
|
7
|
|
|
* @link https://developer.github.com/v3/repos/statistics/ |
|
8
|
|
|
* @package FlexyProject\GitHub\Receiver\Repositories |
|
9
|
|
|
*/ |
|
10
|
|
|
class Statistics extends AbstractRepositories |
|
11
|
|
|
{ |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Get contributors list with additions, deletions, and commit counts |
|
15
|
|
|
* |
|
16
|
|
|
* @link https://developer.github.com/v3/repos/statistics/#contributors |
|
17
|
|
|
* @return array |
|
18
|
|
|
*/ |
|
19
|
|
|
public function listContributors(): array |
|
20
|
|
|
{ |
|
21
|
|
|
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/stats/contributors', |
|
22
|
|
|
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo())); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Get the last year of commit activity data |
|
27
|
|
|
* |
|
28
|
|
|
* @link https://developer.github.com/v3/repos/statistics/#commit-activity |
|
29
|
|
|
* @return array |
|
30
|
|
|
*/ |
|
31
|
|
|
public function getCommitActivity(): array |
|
32
|
|
|
{ |
|
33
|
|
|
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/stats/commit_activity', |
|
34
|
|
|
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo())); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Get the number of additions and deletions per week |
|
39
|
|
|
* |
|
40
|
|
|
* @link https://developer.github.com/v3/repos/statistics/#code-frequency |
|
41
|
|
|
* @return array |
|
42
|
|
|
*/ |
|
43
|
|
|
public function getCodeFrequency(): array |
|
44
|
|
|
{ |
|
45
|
|
|
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/stats/code_frequency', |
|
46
|
|
|
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo())); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Get the weekly commit count for the repository owner and everyone else |
|
51
|
|
|
* |
|
52
|
|
|
* @link https://developer.github.com/v3/repos/statistics/#participation |
|
53
|
|
|
* @return array |
|
54
|
|
|
*/ |
|
55
|
|
|
public function getParticipation(): array |
|
56
|
|
|
{ |
|
57
|
|
|
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/stats/participation', |
|
58
|
|
|
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo())); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Get the number of commits per hour in each day |
|
63
|
|
|
* |
|
64
|
|
|
* @link https://developer.github.com/v3/repos/statistics/#punch-card |
|
65
|
|
|
* @return array |
|
66
|
|
|
*/ |
|
67
|
|
|
public function getPunchCard(): array |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/stats/punch_card', |
|
70
|
|
|
$this->getRepositories()->getOwner(), $this->getRepositories()->getRepo())); |
|
71
|
|
|
} |
|
72
|
|
|
} |