|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Github\Api\CurrentUser; |
| 4 | + |
| 5 | +use Github\Api\AbstractApi; |
| 6 | + |
| 7 | +/** |
| 8 | + * @link https://developer.github.com/v3/activity/starring/ |
| 9 | + * @author Felipe Valtl de Mello <[email protected]> |
| 10 | + */ |
| 11 | +class Starred extends AbstractApi |
| 12 | +{ |
| 13 | + /** |
| 14 | + * List repositories starred by the authenticated user |
| 15 | + * @link https://developer.github.com/v3/activity/starring/ |
| 16 | + * |
| 17 | + * @param integer $page |
| 18 | + * @return array |
| 19 | + */ |
| 20 | + public function all($page = 1) |
| 21 | + { |
| 22 | + return $this->get('user/starred', array( |
| 23 | + 'page' => $page |
| 24 | + )); |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * Check that the authenticated user starres a repository |
| 29 | + * @link https://developer.github.com/v3/activity/starring/ |
| 30 | + * |
| 31 | + * @param string $username the user who owns the repo |
| 32 | + * @param string $repository the name of the repo |
| 33 | + * @return array |
| 34 | + */ |
| 35 | + public function check($username, $repository) |
| 36 | + { |
| 37 | + return $this->get('user/starred/'.rawurlencode($username).'/'.rawurlencode($repository)); |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * Make the authenticated user star a repository |
| 42 | + * @link https://developer.github.com/v3/activity/starring/ |
| 43 | + * |
| 44 | + * @param string $username the user who owns the repo |
| 45 | + * @param string $repository the name of the repo |
| 46 | + * @return array |
| 47 | + */ |
| 48 | + public function star($username, $repository) |
| 49 | + { |
| 50 | + return $this->put('user/starred/'.rawurlencode($username).'/'.rawurlencode($repository)); |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * Make the authenticated user unstar a repository |
| 55 | + * @link https://developer.github.com/v3/activity/starring |
| 56 | + * |
| 57 | + * @param string $username the user who owns the repo |
| 58 | + * @param string $repository the name of the repo |
| 59 | + * @return array |
| 60 | + */ |
| 61 | + public function unstar($username, $repository) |
| 62 | + { |
| 63 | + return $this->delete('user/starred/'.rawurlencode($username).'/'.rawurlencode($repository)); |
| 64 | + } |
| 65 | +} |
0 commit comments