1 | <?php namespace Scriptotek\Sru; |
||
16 | class Client |
||
17 | { |
||
18 | /** @var HttpClient */ |
||
19 | protected $httpClient; |
||
20 | |||
21 | /** @var MessageFactory */ |
||
22 | protected $messageFactory; |
||
23 | |||
24 | /** @var string SRU service base URL */ |
||
25 | protected $url; |
||
26 | |||
27 | /** @var string Requested schema for the returned records */ |
||
28 | protected $schema; |
||
29 | |||
30 | /** @var string SRU protocol version */ |
||
31 | protected $version; |
||
32 | |||
33 | /** @var string Some user agent string to identify our client */ |
||
34 | protected $userAgent; |
||
35 | |||
36 | /** @var array Custom headers */ |
||
37 | public $headers; |
||
38 | |||
39 | /** |
||
40 | * @var string|string[] Proxy configuration details. |
||
41 | * |
||
42 | * Either a string 'host:port' or an |
||
43 | * array('host:port', 'username', 'password'). |
||
44 | */ |
||
45 | protected $proxy; |
||
46 | |||
47 | /** |
||
48 | * @var string[] Array containing username and password |
||
49 | */ |
||
50 | protected $credentials; |
||
51 | |||
52 | /** |
||
53 | * Create a new client |
||
54 | * |
||
55 | * @param string $url Base URL to the SRU service |
||
56 | * @param array $options Associative array of options |
||
57 | * @param HttpClient $httpClient |
||
58 | * @param MessageFactory|null $messageFactory |
||
59 | * @throws \ErrorException |
||
60 | */ |
||
61 | public function __construct( |
||
101 | |||
102 | /** |
||
103 | * Construct the URL for a CQL query |
||
104 | * |
||
105 | * @param string $cql The CQL query |
||
106 | * @param int $start Start value in result set (optional) |
||
107 | * @param int $count Number of records to request (optional) |
||
108 | * @param array $extraParams Extra GET parameters |
||
109 | * @return string |
||
110 | */ |
||
111 | public function urlTo($cql, $start = 1, $count = 10, $extraParams = array()) |
||
133 | |||
134 | /** |
||
135 | * Perform a searchRetrieve request |
||
136 | * |
||
137 | * @deprecated |
||
138 | * @param string $cql |
||
139 | * @param int $start Start value in result set (optional) |
||
140 | * @param int $count Number of records to request (optional) |
||
141 | * @param array $extraParams Extra GET parameters |
||
142 | * @return SearchRetrieveResponse |
||
143 | */ |
||
144 | public function search($cql, $start = 1, $count = 10, $extraParams = array()) |
||
151 | |||
152 | /** |
||
153 | * Perform a searchRetrieve request and return an iterator over the records |
||
154 | * |
||
155 | * @param string $cql |
||
156 | * @param int $batchSize Number of records to request per request |
||
157 | * @param array $extraParams Extra GET parameters |
||
158 | * @return Records |
||
159 | */ |
||
160 | public function all($cql, $batchSize = 10, $extraParams = array()) |
||
164 | |||
165 | /** |
||
166 | * Alias for `all()` |
||
167 | * @deprecated |
||
168 | * @param $cql |
||
169 | * @param int $batchSize |
||
170 | * @param array $extraParams |
||
171 | * @return Records |
||
172 | */ |
||
173 | public function records($cql, $batchSize = 10, $extraParams = array()) |
||
177 | |||
178 | /** |
||
179 | * Perform a searchRetrieve request and return first record |
||
180 | * |
||
181 | * @param string $cql |
||
182 | * @param array $extraParams Extra GET parameters |
||
183 | * @return Record |
||
184 | */ |
||
185 | public function first($cql, $extraParams = array()) |
||
190 | |||
191 | /** |
||
192 | * Perform an explain request |
||
193 | * |
||
194 | * @return ExplainResponse |
||
195 | */ |
||
196 | public function explain() |
||
207 | |||
208 | /** |
||
209 | * @param string $method |
||
210 | * @param string $url |
||
211 | * @return string |
||
212 | */ |
||
213 | public function request($method, $url) |
||
224 | } |
||
225 |