|
16 | 16 | */
|
17 | 17 | class Search extends AbstractApi
|
18 | 18 | {
|
| 19 | + |
| 20 | + /** |
| 21 | + * Search repositories by filter (q) |
| 22 | + * @link https://developer.github.com/v3/search/#search-repositories |
| 23 | + * |
| 24 | + * @param string $q the filter |
| 25 | + * @param string $sort the sort field |
| 26 | + * @param string $order asc/desc |
| 27 | + * |
| 28 | + * @return array list of repositories found |
| 29 | + */ |
| 30 | + public function repositories($q, $sort = 'updated', $order = 'desc') |
| 31 | + { |
| 32 | + return $this->get("/search/repositories", array('q' => $q, 'sort' => $sort, 'order' => $order)); |
| 33 | + } |
| 34 | + |
19 | 35 | /**
|
20 |
| - * Search by filter (q) |
21 |
| - * @link http://developer.github.com/v3/search/ |
| 36 | + * Search issues by filter (q) |
| 37 | + * @link https://developer.github.com/v3/search/#search-issues |
22 | 38 | *
|
23 |
| - * @param string $type the search type |
24 | 39 | * @param string $q the filter
|
25 | 40 | * @param string $sort the sort field
|
26 | 41 | * @param string $order asc/desc
|
27 | 42 | *
|
28 | 43 | * @return array list of issues found
|
29 | 44 | */
|
30 |
| - public function find($type = 'issues', $q = '', $sort = 'updated', $order = 'desc') |
| 45 | + public function issues($q, $sort = 'updated', $order = 'desc') |
| 46 | + { |
| 47 | + return $this->get("/search/issues", array('q' => $q, 'sort' => $sort, 'order' => $order)); |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * Search code by filter (q) |
| 52 | + * @link https://developer.github.com/v3/search/#search-code |
| 53 | + * |
| 54 | + * @param string $q the filter |
| 55 | + * @param string $sort the sort field |
| 56 | + * @param string $order asc/desc |
| 57 | + * |
| 58 | + * @return array list of code found |
| 59 | + */ |
| 60 | + public function code($q, $sort = 'updated', $order = 'desc') |
| 61 | + { |
| 62 | + return $this->get("/search/code", array('q' => $q, 'sort' => $sort, 'order' => $order)); |
| 63 | + } |
| 64 | + |
| 65 | + /** |
| 66 | + * Search users by filter (q) |
| 67 | + * @link https://developer.github.com/v3/search/#search-users |
| 68 | + * |
| 69 | + * @param string $q the filter |
| 70 | + * @param string $sort the sort field |
| 71 | + * @param string $order asc/desc |
| 72 | + * |
| 73 | + * @return array list of users found |
| 74 | + */ |
| 75 | + public function users($q, $sort = 'updated', $order = 'desc') |
31 | 76 | {
|
32 |
| - if (!in_array($type, array('issues', 'repositories', 'code', 'users'))) { |
33 |
| - $type = 'issues'; |
34 |
| - } |
35 |
| - return $this->get("/search/$type", array('q' => $q, 'sort' => $sort, 'order' => $order)); |
| 77 | + return $this->get("/search/users", array('q' => $q, 'sort' => $sort, 'order' => $order)); |
36 | 78 | }
|
37 | 79 |
|
38 | 80 | }
|
0 commit comments