1 | <?php |
||
19 | class Client |
||
20 | { |
||
21 | public $baseUrl; |
||
22 | |||
23 | /** @var string Alma zone (institution or network) */ |
||
24 | public $zone; |
||
25 | |||
26 | /** @var string Alma Developers Network API key for this zone */ |
||
27 | public $key; |
||
28 | |||
29 | /** @var Client Network zone instance */ |
||
30 | public $nz; |
||
31 | |||
32 | /** @var HttpClient */ |
||
33 | protected $httpClient; |
||
34 | |||
35 | /** @var SruClient */ |
||
36 | public $sru; |
||
37 | |||
38 | /** @var Bibs */ |
||
39 | public $bibs; |
||
40 | |||
41 | /** @var Analytics */ |
||
42 | public $analytics; |
||
43 | |||
44 | /** @var Users */ |
||
45 | public $users; |
||
46 | |||
47 | /** |
||
48 | * Create a new client to connect to a given Alma instance. |
||
49 | * |
||
50 | * @param string $key API key |
||
51 | * @param string $region Hosted region code, used to build base URL |
||
52 | * @param string $zone Alma zone (Either Zones::INSTITUTION or Zones::NETWORK) |
||
53 | * @param HttpClient $httpClient |
||
54 | * |
||
55 | * @throws \ErrorException |
||
56 | */ |
||
57 | public function __construct($key = null, $region = 'eu', $zone = Zones::INSTITUTION, HttpClient $httpClient = null) |
||
72 | |||
73 | /** |
||
74 | * Attach an SRU client (so you can search for Bib records). |
||
75 | * |
||
76 | * @param SruClient $sru |
||
77 | */ |
||
78 | public function setSruClient(SruClient $sru) |
||
82 | |||
83 | /** |
||
84 | * Assert that an SRU client is connected. Throws SruClientNotSetException if not. |
||
85 | * |
||
86 | * @throws SruClientNotSetException |
||
87 | */ |
||
88 | public function assertHasSruClient() |
||
94 | |||
95 | /** |
||
96 | * Set the API key for this Alma instance. |
||
97 | * |
||
98 | * @param string $key The API key |
||
99 | * @return $this |
||
100 | */ |
||
101 | public function setKey($key) |
||
107 | |||
108 | /** |
||
109 | * Set the Alma region code ('na' for North America, 'eu' for Europe, 'ap' for Asia Pacific). |
||
110 | * |
||
111 | * @param $regionCode |
||
112 | * @return $this |
||
113 | * @throws \ErrorException |
||
114 | */ |
||
115 | public function setRegion($regionCode) |
||
124 | |||
125 | /** |
||
126 | * @param $url |
||
127 | * |
||
128 | * @return string |
||
129 | */ |
||
130 | protected function getFullUrl($url) |
||
134 | |||
135 | /** |
||
136 | * @param array $options |
||
137 | * |
||
138 | * @return array |
||
139 | */ |
||
140 | protected function getHttpOptions($options = []) |
||
151 | |||
152 | /** |
||
153 | * Make a HTTP request. |
||
154 | * |
||
155 | * @param string $method |
||
156 | * @param string $url |
||
157 | * @param array $options |
||
158 | * |
||
159 | * @return \Psr\Http\Message\ResponseInterface |
||
160 | */ |
||
161 | public function request($method, $url, $options = []) |
||
169 | |||
170 | public function handleError(GuzzleClientException $response) |
||
177 | |||
178 | /** |
||
179 | * Make a GET request. |
||
180 | * |
||
181 | * @param string $url |
||
182 | * @param array $query |
||
183 | * @param string $contentType |
||
184 | * @return string Response body |
||
185 | */ |
||
186 | public function get($url, $query = [], $contentType = 'application/json') |
||
195 | |||
196 | /** |
||
197 | * Make a GET request, accepting JSON. |
||
198 | * |
||
199 | * @param string $url |
||
200 | * @param array $query |
||
201 | * |
||
202 | * @return \stdClass JSON response as an object. |
||
203 | */ |
||
204 | public function getJSON($url, $query = []) |
||
210 | |||
211 | /** |
||
212 | * Make a GET request, accepting XML. |
||
213 | * |
||
214 | * @param string $url |
||
215 | * @param array $query |
||
216 | * |
||
217 | * @return QuiteSimpleXMLElement |
||
218 | */ |
||
219 | public function getXML($url, $query = []) |
||
225 | |||
226 | /** |
||
227 | * Make a PUT request. |
||
228 | * |
||
229 | * @param string $url |
||
230 | * @param $data |
||
231 | * @param string $contentType |
||
232 | * @return bool |
||
233 | */ |
||
234 | public function put($url, $data, $contentType = 'application/json') |
||
247 | |||
248 | /** |
||
249 | * Make a PUT request, sending JSON data. |
||
250 | * |
||
251 | * @param string $url |
||
252 | * @param $data |
||
253 | * |
||
254 | * @return bool |
||
255 | */ |
||
256 | public function putJSON($url, $data) |
||
262 | |||
263 | /** |
||
264 | * Make a PUT request, sending XML data. |
||
265 | * |
||
266 | * @param string $url |
||
267 | * @param $data |
||
268 | * |
||
269 | * @return bool |
||
270 | */ |
||
271 | public function putXML($url, $data) |
||
275 | |||
276 | /** |
||
277 | * Get the redirect target location of an URL, or null if not a redirect. |
||
278 | * |
||
279 | * @param string $url |
||
280 | * @param array $query |
||
281 | * |
||
282 | * @return string|null |
||
283 | */ |
||
284 | public function getRedirectLocation($url, $query = []) |
||
300 | } |
||
301 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: