1 | <?php |
||
16 | class LibrariesioRepository extends Component |
||
17 | { |
||
18 | /** |
||
19 | * @var string Base URI for https://libraries.io |
||
20 | */ |
||
21 | public $baseUri = 'https://libraries.io/api/'; |
||
22 | |||
23 | /** |
||
24 | * Without api key, has 30/request/minute hate limit |
||
25 | * With api key, has 60/request/minute hate limit. |
||
26 | * @var string The user API Key |
||
27 | */ |
||
28 | public $apiKey; |
||
29 | |||
30 | /** |
||
31 | * Options for Guzzle client |
||
32 | * Example: |
||
33 | * [ |
||
34 | * 'timeout' => 0, |
||
35 | * 'allow_redirects' => false, |
||
36 | * 'proxy' => '192.168.16.1:10' |
||
37 | * ]. |
||
38 | * |
||
39 | * @var array |
||
40 | */ |
||
41 | public $clientOptions = []; |
||
42 | |||
43 | /** |
||
44 | * The Guzzle client. |
||
45 | * @var Client |
||
46 | */ |
||
47 | protected $client; |
||
48 | |||
49 | public function init() |
||
57 | |||
58 | /** |
||
59 | * Send request to server with api_key and return a Response. |
||
60 | * @param string $method |
||
61 | * @param string $uri |
||
62 | * @param array $options |
||
63 | * @throws \GuzzleHttp\Exception\BadResponseException |
||
64 | * @return \GuzzleHttp\Psr7\Response |
||
65 | */ |
||
66 | public function request($method, $uri = '', array $options = []) |
||
84 | |||
85 | /** |
||
86 | * Search package in https://libraries.io. |
||
87 | * @see https://libraries.io/api/#project-search |
||
88 | * @param array $query |
||
89 | * @return \GuzzleHttp\Psr7\Response |
||
90 | */ |
||
91 | public function search($query = []) |
||
95 | |||
96 | /** |
||
97 | * Return the package info from https://libraries.io. |
||
98 | * @see https://libraries.io/api/#project |
||
99 | * @param string $platform |
||
100 | * @param string $name |
||
101 | * @return \GuzzleHttp\Psr7\Response |
||
102 | */ |
||
103 | public function getProject($platform, $name) |
||
107 | } |
||
108 |