@@ -174,27 +174,98 @@ public function __construct(array $settings)
174174 }
175175
176176 /**
177- * Does a PROPFIND request.
177+ * Does a PROPFIND request with filtered response returning only available properties .
178178 *
179179 * The list of requested properties must be specified as an array, in clark
180180 * notation.
181181 *
182- * The returned array will contain a list of filenames as keys, and
183- * properties as values.
182+ * Depth should be either 0 or 1. A depth of 1 will cause a request to be
183+ * made to the server to also return all child resources.
184+ *
185+ * For depth 0, just the array of properties for the resource is returned.
186+ *
187+ * For depth 1, the returned array will contain a list of resource names as keys,
188+ * and an array of properties as values.
184189 *
185- * The properties array will contain the list of properties. Only properties
186- * that are actually returned from the server ( without error) will be
190+ * The array of properties will contain the properties as keys with their values as the value.
191+ * Only properties that are actually returned from the server without error will be
187192 * returned, anything else is discarded.
188193 *
194+ * @param 1|0 $depth
195+ */
196+ public function propFind (string $ url , array $ properties , int $ depth = 0 ): array
197+ {
198+ $ result = $ this ->doPropFind ($ url , $ properties , $ depth );
199+
200+ // If depth was 0, we only return the top item
201+ if (0 === $ depth ) {
202+ reset ($ result );
203+ $ result = current ($ result );
204+
205+ return isset ($ result [200 ]) ? $ result [200 ] : [];
206+ }
207+
208+ $ newResult = [];
209+ foreach ($ result as $ href => $ statusList ) {
210+ $ newResult [$ href ] = isset ($ statusList [200 ]) ? $ statusList [200 ] : [];
211+ }
212+
213+ return $ newResult ;
214+ }
215+
216+ /**
217+ * Does a PROPFIND request with unfiltered response.
218+ *
219+ * The list of requested properties must be specified as an array, in clark
220+ * notation.
221+ *
189222 * Depth should be either 0 or 1. A depth of 1 will cause a request to be
190223 * made to the server to also return all child resources.
191224 *
192- * @param string $url
193- * @param int $depth
225+ * For depth 0, just the multi-level array of status and properties for the resource is returned.
194226 *
195- * @return array
227+ * For depth 1, the returned array will contain a list of resources as keys and
228+ * a multi-level array containing status and properties as value.
229+ *
230+ * The multi-level array of status and properties is formatted the same as what is
231+ * documented for parseMultiStatus.
232+ *
233+ * All properties that are actually returned from the server are returned by this method.
234+ *
235+ * @param 1|0 $depth
236+ */
237+ public function propFindUnfiltered (string $ url , array $ properties , int $ depth = 0 ): array
238+ {
239+ $ result = $ this ->doPropFind ($ url , $ properties , $ depth );
240+
241+ // If depth was 0, we only return the top item
242+ if (0 === $ depth ) {
243+ reset ($ result );
244+
245+ return current ($ result );
246+ } else {
247+ return $ result ;
248+ }
249+ }
250+
251+ /**
252+ * Does a PROPFIND request.
253+ *
254+ * The list of requested properties must be specified as an array, in clark
255+ * notation.
256+ *
257+ * Depth should be either 0 or 1. A depth of 1 will cause a request to be
258+ * made to the server to also return all child resources.
259+ *
260+ * The returned array will contain a list of resources as keys and
261+ * a multi-level array containing status and properties as value.
262+ *
263+ * The multi-level array of status and properties is formatted the same as what is
264+ * documented for parseMultiStatus.
265+ *
266+ * @param 1|0 $depth
196267 */
197- public function propFind ( $ url , array $ properties , $ depth = 0 )
268+ private function doPropFind ( string $ url , array $ properties , int $ depth = 0 ): array
198269 {
199270 $ dom = new \DOMDocument ('1.0 ' , 'UTF-8 ' );
200271 $ dom ->formatOutput = true ;
@@ -232,22 +303,7 @@ public function propFind($url, array $properties, $depth = 0)
232303 throw new HTTP \ClientHttpException ($ response );
233304 }
234305
235- $ result = $ this ->parseMultiStatus ($ response ->getBodyAsString ());
236-
237- // If depth was 0, we only return the top item
238- if (0 === $ depth ) {
239- reset ($ result );
240- $ result = current ($ result );
241-
242- return isset ($ result [200 ]) ? $ result [200 ] : [];
243- }
244-
245- $ newResult = [];
246- foreach ($ result as $ href => $ statusList ) {
247- $ newResult [$ href ] = isset ($ statusList [200 ]) ? $ statusList [200 ] : [];
248- }
249-
250- return $ newResult ;
306+ return $ this ->parseMultiStatus ($ response ->getBodyAsString ());
251307 }
252308
253309 /**
0 commit comments