Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions lib/Github/Api/Repo.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function show($username, $repository)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository));
}

/**
* Get extended information about a repository by its id.
* Note: at time of writing this is an undocumented feature but GitHub support have advised that it can be relied on.
Expand Down Expand Up @@ -580,9 +580,23 @@ public function projects()
{
return new Projects($this->client);
}

public function traffic()
{
return new Traffic($this->client);
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a doc block. Preferly with link to docs

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

/**
* @param string $username
* @param string $repository
* @param int $page
*
* @return array|string
*
* @see https://developer.github.com/v3/activity/events/#list-repository-events
*/
public function events($username, $repository, $page = 1)
{
return $this->get('/repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/events', ['page' => $page]);
}
}
20 changes: 19 additions & 1 deletion test/Github/Tests/Api/RepoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function shouldShowRepository()

$this->assertEquals($expectedArray, $api->show('KnpLabs', 'php-github-api'));
}

/**
* @test
*/
Expand Down Expand Up @@ -517,6 +517,24 @@ public function shouldGetCommitActivity()
$this->assertEquals($expectedArray, $api->activity('KnpLabs', 'php-github-api'));
}

/**
* @test
*/
public function shouldGetRepositoryEvents()
{
$expectedArray = array('id' => 6122723754, 'type' => 'ForkEvent');

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('/repos/KnpLabs/php-github-api/events', array(
'page' => 3,
))
->will($this->returnValue($expectedArray));

$this->assertEquals($expectedArray, $api->events('KnpLabs', 'php-github-api', 3));
}

/**
* @return string
*/
Expand Down