@@ -53,34 +53,28 @@ class Client
5353 /**
5454 * Create a new client
5555 *
56- * @param string $url Base URL to the SRU service
57- * @param array $options Associative array of options
58- * @param ClientInterface $httpClient
59- * @param RequestFactoryInterface $requestFactory
56+ * @param string $url Base URL to the SRU service
57+ * @param ? array $options Associative array of options
58+ * @param ? ClientInterface $httpClient
59+ * @param ? RequestFactoryInterface $requestFactory
6060 * @throws \ErrorException
6161 */
6262 public function __construct (
63- $ url ,
64- $ options = null ,
63+ string $ url ,
64+ ? array $ options = null ,
6565 ClientInterface $ httpClient = null ,
6666 RequestFactoryInterface $ requestFactory = null
6767 ) {
6868 $ this ->url = $ url ;
69- $ options = $ options ?: array () ;
69+ $ options = $ options ?: [] ;
7070
7171 $ plugins = [];
7272
73- $ this ->schema = isset ($ options ['schema ' ])
74- ? $ options ['schema ' ]
75- : 'marcxml ' ;
73+ $ this ->schema = $ options ['schema ' ] ?? 'marcxml ' ;
7674
77- $ this ->version = isset ($ options ['version ' ])
78- ? $ options ['version ' ]
79- : '1.1 ' ;
75+ $ this ->version = $ options ['version ' ] ?? '1.1 ' ;
8076
81- $ this ->headers = isset ($ options ['headers ' ])
82- ? $ options ['headers ' ]
83- : ['Accept ' => 'application/xml ' ];
77+ $ this ->headers = $ options ['headers ' ] ?? ['Accept ' => 'application/xml ' ];
8478
8579 if (isset ($ options ['user-agent ' ])) {
8680 // legacy option
@@ -93,7 +87,7 @@ public function __construct(
9387 }
9488
9589 if (isset ($ options ['proxy ' ])) {
96- throw new \ErrorException ('Not supported ' );
90+ throw new \ErrorException ('Not supported ' );
9791 }
9892
9993 $ this ->httpClient = new PluginClient ($ httpClient ?: HttpClient::client (), $ plugins );
@@ -109,7 +103,7 @@ public function __construct(
109103 * @param array $extraParams Extra GET parameters
110104 * @return string
111105 */
112- public function urlTo ($ cql , $ start = 1 , $ count = 10 , $ extraParams = array ())
106+ public function urlTo (string $ cql , int $ start = 1 , int $ count = 10 , array $ extraParams = []): string
113107 {
114108 $ qs = array (
115109 'operation ' => 'searchRetrieve ' ,
@@ -135,14 +129,14 @@ public function urlTo($cql, $start = 1, $count = 10, $extraParams = array())
135129 /**
136130 * Perform a searchRetrieve request
137131 *
138- * @deprecated
139132 * @param string $cql
140133 * @param int $start Start value in result set (optional)
141134 * @param int $count Number of records to request (optional)
142135 * @param array $extraParams Extra GET parameters
143136 * @return SearchRetrieveResponse
137+ *@deprecated
144138 */
145- public function search ($ cql , $ start = 1 , $ count = 10 , $ extraParams = array ())
139+ public function search (string $ cql , int $ start = 1 , int $ count = 10 , array $ extraParams = []): SearchRetrieveResponse
146140 {
147141 $ url = $ this ->urlTo ($ cql , $ start , $ count , $ extraParams );
148142 $ body = $ this ->request ('GET ' , $ url );
@@ -158,20 +152,20 @@ public function search($cql, $start = 1, $count = 10, $extraParams = array())
158152 * @param array $extraParams Extra GET parameters
159153 * @return Records
160154 */
161- public function all ($ cql , $ batchSize = 10 , $ extraParams = array ())
155+ public function all (string $ cql , int $ batchSize = 10 , array $ extraParams = []): Records
162156 {
163157 return new Records ($ cql , $ this , $ batchSize , $ extraParams );
164158 }
165159
166160 /**
167161 * Alias for `all()`
168- * @deprecated
169- * @param $cql
162+ * @param string $cql
170163 * @param int $batchSize
171164 * @param array $extraParams
172165 * @return Records
166+ *@deprecated
173167 */
174- public function records ($ cql , $ batchSize = 10 , $ extraParams = array ())
168+ public function records (string $ cql , int $ batchSize = 10 , array $ extraParams = []): Records
175169 {
176170 return $ this ->all ($ cql , $ batchSize , $ extraParams );
177171 }
@@ -181,9 +175,9 @@ public function records($cql, $batchSize = 10, $extraParams = array())
181175 *
182176 * @param string $cql
183177 * @param array $extraParams Extra GET parameters
184- * @return Record
178+ * @return ? Record
185179 */
186- public function first ($ cql , $ extraParams = array ())
180+ public function first (string $ cql , array $ extraParams = []): ? Record
187181 {
188182 $ recs = new Records ($ cql , $ this , 1 , $ extraParams );
189183 return $ recs ->numberOfRecords () ? $ recs ->current () : null ;
@@ -194,7 +188,7 @@ public function first($cql, $extraParams = array())
194188 *
195189 * @return ExplainResponse
196190 */
197- public function explain ()
191+ public function explain (): ExplainResponse
198192 {
199193 $ url = $ this ->url . '? ' . http_build_query (array (
200194 'operation ' => 'explain ' ,
@@ -211,7 +205,7 @@ public function explain()
211205 * @param string $url
212206 * @return string
213207 */
214- public function request ($ method , $ url )
208+ public function request (string $ method , string $ url ): string
215209 {
216210 $ request = $ this ->requestFactory ->createRequest ($ method , $ url , $ this ->headers );
217211 $ response = $ this ->httpClient ->sendRequest ($ request );
0 commit comments