|
1
|
|
|
<?php |
|
2
|
|
|
namespace FlexyProject\GitHub\Receiver; |
|
3
|
|
|
|
|
4
|
|
|
use FlexyProject\GitHub\AbstractApi; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* This class give you access to the Search API. |
|
8
|
|
|
* |
|
9
|
|
|
* @link https://developer.github.com/v3/search/ |
|
10
|
|
|
* @package FlexyProject\GitHub\Receiver |
|
11
|
|
|
*/ |
|
12
|
|
|
class Search extends AbstractReceiver |
|
13
|
|
|
{ |
|
14
|
|
|
|
|
15
|
|
|
/** Available sub-Receiver */ |
|
16
|
|
|
const REPOSITORIES = 'Repositories'; |
|
17
|
|
|
const CODE = 'Code'; |
|
18
|
|
|
const ISSUES = 'Issues'; |
|
19
|
|
|
const USERS = 'Users'; |
|
20
|
|
|
const LEGACY_SEARCH = 'LegacySearch'; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Search repositories |
|
24
|
|
|
* |
|
25
|
|
|
* @link https://developer.github.com/v3/search/#search-repositories |
|
26
|
|
|
* |
|
27
|
|
|
* @param string $q |
|
28
|
|
|
* @param string $sort |
|
29
|
|
|
* @param string $order |
|
30
|
|
|
* |
|
31
|
|
|
* @return array |
|
32
|
|
|
* @throws \Exception |
|
33
|
|
|
*/ |
|
34
|
|
|
public function searchRepositories(string $q, string $sort = null, |
|
35
|
|
|
string $order = AbstractApi::DIRECTION_DESC): array |
|
36
|
|
|
{ |
|
37
|
|
|
return $this->getApi()->request($this->getApi()->sprintf('/search/repositories?:args', |
|
38
|
|
|
http_build_query(['q' => $q, 'sort' => $sort, 'order' => $order]))); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Search code |
|
43
|
|
|
* |
|
44
|
|
|
* @link https://developer.github.com/v3/search/#search-code |
|
45
|
|
|
* |
|
46
|
|
|
* @param string $q |
|
47
|
|
|
* @param string $sort |
|
48
|
|
|
* @param string $order |
|
49
|
|
|
* |
|
50
|
|
|
* @return array |
|
51
|
|
|
* @throws \Exception |
|
52
|
|
|
*/ |
|
53
|
|
|
public function searchCode(string $q, string $sort = null, string $order = AbstractApi::DIRECTION_DESC): array |
|
54
|
|
|
{ |
|
55
|
|
|
return $this->getApi()->request($this->getApi()->sprintf('/search/code?:args', |
|
56
|
|
|
http_build_query(['q' => $q, 'sort' => $sort, 'order' => $order]))); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Search issues |
|
61
|
|
|
* |
|
62
|
|
|
* @link https://developer.github.com/v3/search/#search-issues |
|
63
|
|
|
* |
|
64
|
|
|
* @param string $q |
|
65
|
|
|
* @param string $sort |
|
66
|
|
|
* @param string $order |
|
67
|
|
|
* |
|
68
|
|
|
* @return array |
|
69
|
|
|
* @throws \Exception |
|
70
|
|
|
*/ |
|
71
|
|
|
public function searchIssues(string $q, string $sort = null, string $order = AbstractApi::DIRECTION_DESC): array |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->getApi()->request($this->getApi()->sprintf('/search/issues?:args', |
|
74
|
|
|
http_build_query(['q' => $q, 'sort' => $sort, 'order' => $order]))); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Search users |
|
79
|
|
|
* |
|
80
|
|
|
* @link https://developer.github.com/v3/search/#search-users |
|
81
|
|
|
* |
|
82
|
|
|
* @param string $q |
|
83
|
|
|
* @param string $sort |
|
84
|
|
|
* @param string $order |
|
85
|
|
|
* |
|
86
|
|
|
* @return array |
|
87
|
|
|
* @throws \Exception |
|
88
|
|
|
*/ |
|
89
|
|
|
public function searchUsers(string $q, string $sort = null, string $order = AbstractApi::DIRECTION_DESC): array |
|
90
|
|
|
{ |
|
91
|
|
|
return $this->getApi()->request($this->getApi()->sprintf('/search/users?:args', |
|
92
|
|
|
http_build_query(['q' => $q, 'sort' => $sort, 'order' => $order]))); |
|
93
|
|
|
} |
|
94
|
|
|
} |