Skip to content

Commit 3dd65b7

Browse files
committed
Split find into 4 methods.
1 parent 1e929f3 commit 3dd65b7

File tree

1 file changed

+50
-8
lines changed

1 file changed

+50
-8
lines changed

lib/Github/Api/Search.php

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,65 @@
1616
*/
1717
class Search extends AbstractApi
1818
{
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+
1935
/**
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
2238
*
23-
* @param string $type the search type
2439
* @param string $q the filter
2540
* @param string $sort the sort field
2641
* @param string $order asc/desc
2742
*
2843
* @return array list of issues found
2944
*/
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')
3176
{
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));
3678
}
3779

3880
}

0 commit comments

Comments
 (0)