@@ -46,14 +46,14 @@ |
||
46 | 46 | * @param DateTime $from |
47 | 47 | * @param DateTime $to |
48 | 48 | */ |
49 | - public function __construct($get_etags = true, $get_calendar_data = false, DateTime $from = null, DateTime $to = null) |
|
49 | + public function __construct($get_etags = true, $get_calendar_data = false, DateTime $from = null, DateTime $to = null) |
|
50 | 50 | { |
51 | 51 | $this->get_etags = $get_etags; |
52 | 52 | $this->get_calendar_data = $get_calendar_data; |
53 | 53 | $this->from = $from; |
54 | 54 | $this->to = $to; |
55 | 55 | |
56 | - if(!is_null($this->from) && !is_null($this->to) && $this->from > $this->to) |
|
56 | + if (!is_null($this->from) && !is_null($this->to) && $this->from > $this->to) |
|
57 | 57 | throw new \InvalidArgumentException("from should be lower than to param"); |
58 | 58 | } |
59 | 59 |
@@ -53,8 +53,9 @@ |
||
53 | 53 | $this->from = $from; |
54 | 54 | $this->to = $to; |
55 | 55 | |
56 | - if(!is_null($this->from) && !is_null($this->to) && $this->from > $this->to) |
|
57 | - throw new \InvalidArgumentException("from should be lower than to param"); |
|
56 | + if(!is_null($this->from) && !is_null($this->to) && $this->from > $this->to) { |
|
57 | + throw new \InvalidArgumentException("from should be lower than to param"); |
|
58 | + } |
|
58 | 59 | } |
59 | 60 | |
60 | 61 | /** |
@@ -30,13 +30,13 @@ |
||
30 | 30 | * @param string $type |
31 | 31 | * @return array |
32 | 32 | */ |
33 | - public function getResponseByType($type){ |
|
33 | + public function getResponseByType($type) { |
|
34 | 34 | $responses = []; |
35 | 35 | |
36 | - foreach ($this->getResponses() as $response){ |
|
37 | - if(!$response instanceof GetCalendarResponse) continue; |
|
36 | + foreach ($this->getResponses() as $response) { |
|
37 | + if (!$response instanceof GetCalendarResponse) continue; |
|
38 | 38 | $resource_types = $response->getResourceType(); |
39 | - if(in_array($type, array_keys($resource_types))) $responses[] = $response; |
|
39 | + if (in_array($type, array_keys($resource_types))) $responses[] = $response; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | return $responses; |
@@ -34,9 +34,13 @@ |
||
34 | 34 | $responses = []; |
35 | 35 | |
36 | 36 | foreach ($this->getResponses() as $response){ |
37 | - if(!$response instanceof GetCalendarResponse) continue; |
|
37 | + if(!$response instanceof GetCalendarResponse) { |
|
38 | + continue; |
|
39 | + } |
|
38 | 40 | $resource_types = $response->getResourceType(); |
39 | - if(in_array($type, array_keys($resource_types))) $responses[] = $response; |
|
41 | + if(in_array($type, array_keys($resource_types))) { |
|
42 | + $responses[] = $response; |
|
43 | + } |
|
40 | 44 | } |
41 | 45 | |
42 | 46 | return $responses; |
@@ -175,8 +175,7 @@ |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | return $this->client->send($http_request, $options); |
178 | - } |
|
179 | - catch (ClientException $ex){ |
|
178 | + } catch (ClientException $ex){ |
|
180 | 179 | switch($ex->getCode()){ |
181 | 180 | case 401: |
182 | 181 | throw new UserUnAuthorizedException(); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @param string $authtype |
109 | 109 | * @param array $headers Additional headers to send with each request |
110 | 110 | */ |
111 | - public function __construct($server_url, $user = null, $password = null, $authtype = self::DefaultAuthType, $headers=[]) |
|
111 | + public function __construct($server_url, $user = null, $password = null, $authtype = self::DefaultAuthType, $headers = []) |
|
112 | 112 | { |
113 | 113 | $this->server_url = $server_url; |
114 | 114 | $this->user = $user; |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | * @return mixed|\Psr\Http\Message\ResponseInterface |
158 | 158 | * @throws \GuzzleHttp\Exception\GuzzleException |
159 | 159 | */ |
160 | - private function makeRequest(Request $http_request){ |
|
161 | - try{ |
|
160 | + private function makeRequest(Request $http_request) { |
|
161 | + try { |
|
162 | 162 | $options = [ |
163 | 163 | 'timeout' => $this->timeout |
164 | 164 | ]; |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | |
177 | 177 | return $this->client->send($http_request, $options); |
178 | 178 | } |
179 | - catch (ClientException $ex){ |
|
180 | - switch($ex->getCode()){ |
|
179 | + catch (ClientException $ex) { |
|
180 | + switch ($ex->getCode()) { |
|
181 | 181 | case 401: |
182 | 182 | throw new UserUnAuthorizedException(); |
183 | 183 | break; |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | |
211 | 211 | $res = $http_response->hasHeader(self::DAVHeader); |
212 | 212 | $options = []; |
213 | - if($res){ |
|
213 | + if ($res) { |
|
214 | 214 | $val = $http_response->getHeaderLine(self::DAVHeader); |
215 | - if(!empty($val)){ |
|
215 | + if (!empty($val)) { |
|
216 | 216 | $options = explode(', ', $val); |
217 | 217 | } |
218 | 218 | } |
@@ -226,15 +226,14 @@ discard block |
||
226 | 226 | public function getUserPrincipal() |
227 | 227 | { |
228 | 228 | $http_response = $this->makeRequest( |
229 | - RequestFactory::createPropFindRequest |
|
230 | - ( |
|
229 | + RequestFactory::createPropFindRequest( |
|
231 | 230 | $this->server_url, |
232 | 231 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::PrincipalRequestType)->getContent(), |
233 | 232 | 0 |
234 | 233 | ) |
235 | 234 | ); |
236 | 235 | |
237 | - return new UserPrincipalResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); |
|
236 | + return new UserPrincipalResponse($this->server_url, (string) $http_response->getBody(), $http_response->getStatusCode()); |
|
238 | 237 | } |
239 | 238 | |
240 | 239 | /** |
@@ -245,15 +244,14 @@ discard block |
||
245 | 244 | public function getCalendarHome($principal_url) |
246 | 245 | { |
247 | 246 | $http_response = $this->makeRequest( |
248 | - RequestFactory::createPropFindRequest |
|
249 | - ( |
|
247 | + RequestFactory::createPropFindRequest( |
|
250 | 248 | $principal_url, |
251 | 249 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarHomeRequestType)->getContent(), |
252 | 250 | 0 |
253 | 251 | ) |
254 | 252 | ); |
255 | 253 | |
256 | - return new CalendarHomesResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); |
|
254 | + return new CalendarHomesResponse($this->server_url, (string) $http_response->getBody(), $http_response->getStatusCode()); |
|
257 | 255 | } |
258 | 256 | |
259 | 257 | /** |
@@ -268,10 +266,9 @@ discard block |
||
268 | 266 | $uid = $vo->getUID(); |
269 | 267 | $resource_name = $vo->getResourceName(); |
270 | 268 | |
271 | - $resource_url = $calendar_home_set . ($resource_name ? $resource_name : $uid); |
|
269 | + $resource_url = $calendar_home_set.($resource_name ? $resource_name : $uid); |
|
272 | 270 | $http_response = $this->makeRequest( |
273 | - RequestFactory::createMakeCalendarRequest |
|
274 | - ( |
|
271 | + RequestFactory::createMakeCalendarRequest( |
|
275 | 272 | $resource_url, |
276 | 273 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarCreateRequestType, [$vo])->getContent() |
277 | 274 | ) |
@@ -288,14 +285,13 @@ discard block |
||
288 | 285 | public function getCalendars($calendar_home_set_url) |
289 | 286 | { |
290 | 287 | $http_response = $this->makeRequest( |
291 | - RequestFactory::createPropFindRequest |
|
292 | - ( |
|
288 | + RequestFactory::createPropFindRequest( |
|
293 | 289 | $calendar_home_set_url, |
294 | 290 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarsRequestType)->getContent() |
295 | 291 | ) |
296 | 292 | ); |
297 | 293 | |
298 | - return new GetCalendarsResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); |
|
294 | + return new GetCalendarsResponse($this->server_url, (string) $http_response->getBody(), $http_response->getStatusCode()); |
|
299 | 295 | } |
300 | 296 | |
301 | 297 | /** |
@@ -306,15 +302,14 @@ discard block |
||
306 | 302 | public function getCalendar($calendar_url) |
307 | 303 | { |
308 | 304 | $http_response = $this->makeRequest( |
309 | - RequestFactory::createPropFindRequest |
|
310 | - ( |
|
305 | + RequestFactory::createPropFindRequest( |
|
311 | 306 | $calendar_url, |
312 | 307 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarRequestType)->getContent(), |
313 | 308 | 0 |
314 | 309 | ) |
315 | 310 | ); |
316 | 311 | |
317 | - return new GetCalendarResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); |
|
312 | + return new GetCalendarResponse($this->server_url, (string) $http_response->getBody(), $http_response->getStatusCode()); |
|
318 | 313 | } |
319 | 314 | |
320 | 315 | |
@@ -328,14 +323,13 @@ discard block |
||
328 | 323 | { |
329 | 324 | |
330 | 325 | $http_response = $this->makeRequest( |
331 | - RequestFactory::createReportRequest |
|
332 | - ( |
|
326 | + RequestFactory::createReportRequest( |
|
333 | 327 | $calendar_url, |
334 | 328 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarSyncRequestType, [$sync_token])->getContent() |
335 | 329 | ) |
336 | 330 | ); |
337 | 331 | |
338 | - return new CalendarSyncInfoResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); |
|
332 | + return new CalendarSyncInfoResponse($this->server_url, (string) $http_response->getBody(), $http_response->getStatusCode()); |
|
339 | 333 | } |
340 | 334 | |
341 | 335 | /** |
@@ -349,19 +343,17 @@ discard block |
||
349 | 343 | $uid = $vo->getUID(); |
350 | 344 | $resource_url = $calendar_url.$uid.self::SchedulingInformationSuffix; |
351 | 345 | $http_response = $this->makeRequest( |
352 | - RequestFactory::createPutRequest |
|
353 | - ( |
|
346 | + RequestFactory::createPutRequest( |
|
354 | 347 | $resource_url, |
355 | 348 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::EventCreateRequestType, [$vo])->getContent() |
356 | 349 | ) |
357 | 350 | ); |
358 | 351 | $etag = $http_response->hasHeader(self::ETagHeader) ? $http_response->getHeaderLine(self::ETagHeader) : null; |
359 | - return new EventCreatedResponse |
|
360 | - ( |
|
352 | + return new EventCreatedResponse( |
|
361 | 353 | $uid, |
362 | 354 | $etag, |
363 | 355 | $resource_url, |
364 | - (string)$http_response->getBody(), |
|
356 | + (string) $http_response->getBody(), |
|
365 | 357 | $http_response->getStatusCode() |
366 | 358 | ); |
367 | 359 | } |
@@ -378,20 +370,18 @@ discard block |
||
378 | 370 | $uid = $vo->getUID(); |
379 | 371 | $resource_url = $calendar_url.$uid.self::SchedulingInformationSuffix; |
380 | 372 | $http_response = $this->makeRequest( |
381 | - RequestFactory::createPutRequest |
|
382 | - ( |
|
373 | + RequestFactory::createPutRequest( |
|
383 | 374 | $resource_url, |
384 | 375 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::EventUpdateRequestType, [$vo])->getContent(), |
385 | 376 | $etag |
386 | 377 | ) |
387 | 378 | ); |
388 | 379 | $etag = $http_response->hasHeader(self::ETagHeader) ? $http_response->getHeaderLine(self::ETagHeader) : null; |
389 | - return new EventUpdatedResponse |
|
390 | - ( |
|
380 | + return new EventUpdatedResponse( |
|
391 | 381 | $uid, |
392 | 382 | $etag, |
393 | 383 | $resource_url, |
394 | - (string)$http_response->getBody(), |
|
384 | + (string) $http_response->getBody(), |
|
395 | 385 | $http_response->getStatusCode() |
396 | 386 | ); |
397 | 387 | } |
@@ -406,16 +396,14 @@ discard block |
||
406 | 396 | public function deleteEvent($calendar_url, $uid, $etag = null) |
407 | 397 | { |
408 | 398 | $http_response = $this->makeRequest( |
409 | - RequestFactory::createDeleteRequest |
|
410 | - ( |
|
399 | + RequestFactory::createDeleteRequest( |
|
411 | 400 | $calendar_url.$uid.self::SchedulingInformationSuffix, |
412 | 401 | $etag |
413 | 402 | ) |
414 | 403 | ); |
415 | 404 | |
416 | - return new EventDeletedResponse |
|
417 | - ( |
|
418 | - (string)$http_response->getBody(), $http_response->getStatusCode() |
|
405 | + return new EventDeletedResponse( |
|
406 | + (string) $http_response->getBody(), $http_response->getStatusCode() |
|
419 | 407 | ); |
420 | 408 | } |
421 | 409 | |
@@ -424,15 +412,14 @@ discard block |
||
424 | 412 | * @return string |
425 | 413 | * @throws \GuzzleHttp\Exception\GuzzleException |
426 | 414 | */ |
427 | - public function getEventVCardBy($event_url){ |
|
415 | + public function getEventVCardBy($event_url) { |
|
428 | 416 | $http_response = $this->makeRequest( |
429 | - RequestFactory::createGetRequest |
|
430 | - ( |
|
417 | + RequestFactory::createGetRequest( |
|
431 | 418 | $event_url |
432 | 419 | ) |
433 | 420 | ); |
434 | 421 | |
435 | - $ical = (string)$http_response->getBody(); |
|
422 | + $ical = (string) $http_response->getBody(); |
|
436 | 423 | return $ical; |
437 | 424 | } |
438 | 425 | |
@@ -445,17 +432,15 @@ discard block |
||
445 | 432 | public function getEventsBy($calendar_url, array $events_urls) |
446 | 433 | { |
447 | 434 | $http_response = $this->makeRequest( |
448 | - RequestFactory::createReportRequest |
|
449 | - ( |
|
435 | + RequestFactory::createReportRequest( |
|
450 | 436 | $calendar_url, |
451 | 437 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarMultiGetRequestType, [$events_urls])->getContent() |
452 | 438 | ) |
453 | 439 | ); |
454 | 440 | |
455 | - return new ResourceCollectionResponse |
|
456 | - ( |
|
441 | + return new ResourceCollectionResponse( |
|
457 | 442 | $this->server_url, |
458 | - (string)$http_response->getBody(), |
|
443 | + (string) $http_response->getBody(), |
|
459 | 444 | $http_response->getStatusCode() |
460 | 445 | ); |
461 | 446 | } |
@@ -470,17 +455,15 @@ discard block |
||
470 | 455 | { |
471 | 456 | |
472 | 457 | $http_response = $this->makeRequest( |
473 | - RequestFactory::createReportRequest |
|
474 | - ( |
|
458 | + RequestFactory::createReportRequest( |
|
475 | 459 | $calendar_url, |
476 | 460 | CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarQueryRequestType, [$filter])->getContent() |
477 | 461 | ) |
478 | 462 | ); |
479 | 463 | |
480 | - return new ResourceCollectionResponse |
|
481 | - ( |
|
464 | + return new ResourceCollectionResponse( |
|
482 | 465 | $this->server_url, |
483 | - (string)$http_response->getBody(), |
|
466 | + (string) $http_response->getBody(), |
|
484 | 467 | $http_response->getStatusCode() |
485 | 468 | ); |
486 | 469 | } |
@@ -494,16 +477,14 @@ discard block |
||
494 | 477 | public function deleteCalendar($calendar_url, $etag = null) |
495 | 478 | { |
496 | 479 | $http_response = $this->makeRequest( |
497 | - RequestFactory::createDeleteRequest |
|
498 | - ( |
|
480 | + RequestFactory::createDeleteRequest( |
|
499 | 481 | $calendar_url, |
500 | 482 | $etag |
501 | 483 | ) |
502 | 484 | ); |
503 | 485 | |
504 | - return new CalendarDeletedResponse |
|
505 | - ( |
|
506 | - (string)$http_response->getBody(), $http_response->getStatusCode() |
|
486 | + return new CalendarDeletedResponse( |
|
487 | + (string) $http_response->getBody(), $http_response->getStatusCode() |
|
507 | 488 | ); |
508 | 489 | } |
509 | 490 | } |
@@ -22,11 +22,11 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @return string |
24 | 24 | */ |
25 | - public function getDisplayName(){ |
|
25 | + public function getDisplayName() { |
|
26 | 26 | return isset($this->found_props['displayname']) ? $this->found_props['displayname'] : null; |
27 | 27 | } |
28 | 28 | |
29 | - public function getResourceType(){ |
|
29 | + public function getResourceType() { |
|
30 | 30 | return isset($this->found_props['resourcetype']) ? $this->found_props['resourcetype'] : null; |
31 | 31 | } |
32 | 32 | |
@@ -34,21 +34,21 @@ discard block |
||
34 | 34 | * @see https://tools.ietf.org/html/rfc6578 |
35 | 35 | * @return string |
36 | 36 | */ |
37 | - public function getSyncToken(){ |
|
37 | + public function getSyncToken() { |
|
38 | 38 | return isset($this->found_props['sync-token']) ? $this->found_props['sync-token'] : null; |
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @return string |
43 | 43 | */ |
44 | - public function getETag(){ |
|
44 | + public function getETag() { |
|
45 | 45 | return isset($this->found_props['getetag']) ? $this->found_props['getetag'] : null; |
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
49 | 49 | * @return string |
50 | 50 | */ |
51 | - public function getCTag(){ |
|
51 | + public function getCTag() { |
|
52 | 52 | return isset($this->found_props['getctag']) ? $this->found_props['getctag'] : null; |
53 | 53 | } |
54 | 54 |
@@ -42,15 +42,15 @@ discard block |
||
42 | 42 | * @param string|null $body |
43 | 43 | * @param int $code |
44 | 44 | */ |
45 | - public function __construct($server_url = null, $body = null, $code = HttpResponse::HttpCodeOk ) |
|
45 | + public function __construct($server_url = null, $body = null, $code = HttpResponse::HttpCodeOk) |
|
46 | 46 | { |
47 | 47 | parent::__construct($body, $code); |
48 | 48 | $this->server_url = $server_url; |
49 | - if(!empty($this->body)) { |
|
49 | + if (!empty($this->body)) { |
|
50 | 50 | $this->stripped = $this->stripNamespacesFromTags($this->body); |
51 | 51 | // Merge CDATA as text nodes |
52 | 52 | $this->xml = simplexml_load_string($this->stripped, null, LIBXML_NOCDATA); |
53 | - if($this->xml === FALSE) |
|
53 | + if ($this->xml === FALSE) |
|
54 | 54 | throw new XMLResponseParseException(); |
55 | 55 | $this->content = $this->toAssocArray($this->xml); |
56 | 56 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | { |
63 | 63 | } |
64 | 64 | |
65 | - protected function setContent($content){ |
|
65 | + protected function setContent($content) { |
|
66 | 66 | $this->content = $content; |
67 | 67 | } |
68 | 68 | |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | $nameSpaceDefRegEx = '(\S+)=["\']?((?:.(?!["\']?\s+(?:\S+)=|[>"\']))+.)["\']?'; |
96 | 96 | |
97 | 97 | // Cycle through each namespace and remove it from the XML string |
98 | - foreach( $toRemove as $remove ) { |
|
98 | + foreach ($toRemove as $remove) { |
|
99 | 99 | // First remove the namespace from the opening of the tag |
100 | - $xml = str_replace('<' . $remove . ':', '<', $xml); |
|
100 | + $xml = str_replace('<'.$remove.':', '<', $xml); |
|
101 | 101 | // Now remove the namespace from the closing of the tag |
102 | - $xml = str_replace('</' . $remove . ':', '</', $xml); |
|
102 | + $xml = str_replace('</'.$remove.':', '</', $xml); |
|
103 | 103 | // This XML uses the name space with CommentText, so remove that too |
104 | - $xml = str_replace($remove . ':commentText', 'commentText', $xml); |
|
104 | + $xml = str_replace($remove.':commentText', 'commentText', $xml); |
|
105 | 105 | // Complete the pattern for RegEx to remove this namespace declaration |
106 | 106 | $pattern = "/xmlns:{$remove}{$nameSpaceDefRegEx}/"; |
107 | 107 | // Remove the actual namespace declaration using the Pattern |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | /** |
126 | 126 | * @return bool |
127 | 127 | */ |
128 | - protected function isValid(){ |
|
128 | + protected function isValid() { |
|
129 | 129 | return isset($this->content['response']); |
130 | 130 | } |
131 | 131 | } |
132 | 132 | \ No newline at end of file |
@@ -50,8 +50,9 @@ |
||
50 | 50 | $this->stripped = $this->stripNamespacesFromTags($this->body); |
51 | 51 | // Merge CDATA as text nodes |
52 | 52 | $this->xml = simplexml_load_string($this->stripped, null, LIBXML_NOCDATA); |
53 | - if($this->xml === FALSE) |
|
54 | - throw new XMLResponseParseException(); |
|
53 | + if($this->xml === FALSE) { |
|
54 | + throw new XMLResponseParseException(); |
|
55 | + } |
|
55 | 56 | $this->content = $this->toAssocArray($this->xml); |
56 | 57 | |
57 | 58 | $this->parse(); |
@@ -21,10 +21,10 @@ |
||
21 | 21 | /** |
22 | 22 | * @return string |
23 | 23 | */ |
24 | - public function getVCard(){ |
|
25 | - if(!isset($this->found_props['calendar-data'])) return null; |
|
24 | + public function getVCard() { |
|
25 | + if (!isset($this->found_props['calendar-data'])) return null; |
|
26 | 26 | $calendar_data = $this->found_props['calendar-data']; |
27 | - if(!is_string($calendar_data)) return null; |
|
27 | + if (!is_string($calendar_data)) return null; |
|
28 | 28 | return $calendar_data; |
29 | 29 | } |
30 | 30 | } |
31 | 31 | \ No newline at end of file |
@@ -22,9 +22,13 @@ |
||
22 | 22 | * @return string |
23 | 23 | */ |
24 | 24 | public function getVCard(){ |
25 | - if(!isset($this->found_props['calendar-data'])) return null; |
|
25 | + if(!isset($this->found_props['calendar-data'])) { |
|
26 | + return null; |
|
27 | + } |
|
26 | 28 | $calendar_data = $this->found_props['calendar-data']; |
27 | - if(!is_string($calendar_data)) return null; |
|
29 | + if(!is_string($calendar_data)) { |
|
30 | + return null; |
|
31 | + } |
|
28 | 32 | return $calendar_data; |
29 | 33 | } |
30 | 34 | } |
31 | 35 | \ No newline at end of file |
@@ -51,27 +51,27 @@ discard block |
||
51 | 51 | case HttpMethods::Put: |
52 | 52 | |
53 | 53 | $len = $params[0]; |
54 | - $etag = $params[1]; |
|
54 | + $etag = $params[1]; |
|
55 | 55 | |
56 | - $headers = [ |
|
57 | - Headers::ContentLength => intval($len), |
|
58 | - Headers::ContentType => ContentTypes::Calendar, |
|
59 | - ]; |
|
56 | + $headers = [ |
|
57 | + Headers::ContentLength => intval($len), |
|
58 | + Headers::ContentType => ContentTypes::Calendar, |
|
59 | + ]; |
|
60 | 60 | |
61 | - if(!empty($etag)){ |
|
62 | - $headers[Headers::IfMatch] = $etag; |
|
63 | - } |
|
61 | + if(!empty($etag)){ |
|
62 | + $headers[Headers::IfMatch] = $etag; |
|
63 | + } |
|
64 | 64 | |
65 | - return $headers; |
|
65 | + return $headers; |
|
66 | 66 | } |
67 | 67 | return []; |
68 | 68 | } |
69 | 69 | /** |
70 | - * @param string $url |
|
71 | - * @param string $body |
|
72 | - * @param int $depth |
|
73 | - * @return Request |
|
74 | - */ |
|
70 | + * @param string $url |
|
71 | + * @param string $body |
|
72 | + * @param int $depth |
|
73 | + * @return Request |
|
74 | + */ |
|
75 | 75 | public static function createPropFindRequest($url , $body, $depth = 1){ |
76 | 76 | return new Request |
77 | 77 | ( |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @param string $etag |
161 | 161 | * @return Request |
162 | 162 | */ |
163 | - public static function createPutRequest($url, $body, $etag = null){ |
|
163 | + public static function createPutRequest($url, $body, $etag = null){ |
|
164 | 164 | |
165 | 165 | return new Request |
166 | 166 | ( |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * @param array $params |
27 | 27 | * @return array |
28 | 28 | */ |
29 | - private static function createHeadersFor($http_method, array $params = []){ |
|
30 | - switch ($http_method){ |
|
29 | + private static function createHeadersFor($http_method, array $params = []) { |
|
30 | + switch ($http_method) { |
|
31 | 31 | case HttpMethods::PropFind: |
32 | 32 | case HttpMethods::Options: |
33 | 33 | case HttpMethods::Report: |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | ]; |
39 | 39 | case HttpMethods::Delete: |
40 | 40 | $etag = $params[0]; |
41 | - if(!empty($etag)) { |
|
41 | + if (!empty($etag)) { |
|
42 | 42 | return [ |
43 | 43 | Headers::IfMatch => $etag, |
44 | 44 | ]; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | Headers::ContentType => ContentTypes::Calendar, |
59 | 59 | ]; |
60 | 60 | |
61 | - if(!empty($etag)){ |
|
61 | + if (!empty($etag)) { |
|
62 | 62 | $headers[Headers::IfMatch] = $etag; |
63 | 63 | } |
64 | 64 | |
@@ -72,11 +72,10 @@ discard block |
||
72 | 72 | * @param int $depth |
73 | 73 | * @return Request |
74 | 74 | */ |
75 | - public static function createPropFindRequest($url , $body, $depth = 1){ |
|
76 | - return new Request |
|
77 | - ( |
|
75 | + public static function createPropFindRequest($url, $body, $depth = 1) { |
|
76 | + return new Request( |
|
78 | 77 | HttpMethods::PropFind, |
79 | - $url , |
|
78 | + $url, |
|
80 | 79 | self::createHeadersFor(HttpMethods::PropFind, [$depth]), |
81 | 80 | $body |
82 | 81 | ); |
@@ -87,9 +86,8 @@ discard block |
||
87 | 86 | * @param string $body |
88 | 87 | * @return Request |
89 | 88 | */ |
90 | - public static function createMakeCalendarRequest($url , $body){ |
|
91 | - return new Request |
|
92 | - ( |
|
89 | + public static function createMakeCalendarRequest($url, $body) { |
|
90 | + return new Request( |
|
93 | 91 | HttpMethods::MakeCalendar, |
94 | 92 | $url, |
95 | 93 | self::createHeadersFor(HttpMethods::MakeCalendar), |
@@ -102,9 +100,8 @@ discard block |
||
102 | 100 | * @param int $depth |
103 | 101 | * @return Request |
104 | 102 | */ |
105 | - public static function createOptionsRequest($url, $depth = 1){ |
|
106 | - return new Request |
|
107 | - ( |
|
103 | + public static function createOptionsRequest($url, $depth = 1) { |
|
104 | + return new Request( |
|
108 | 105 | HttpMethods::Options, |
109 | 106 | $url, |
110 | 107 | self::createHeadersFor(HttpMethods::Options, [$depth]) |
@@ -117,9 +114,8 @@ discard block |
||
117 | 114 | * @param int $depth |
118 | 115 | * @return Request |
119 | 116 | */ |
120 | - public static function createReportRequest($url , $body, $depth = 1){ |
|
121 | - return new Request |
|
122 | - ( |
|
117 | + public static function createReportRequest($url, $body, $depth = 1) { |
|
118 | + return new Request( |
|
123 | 119 | HttpMethods::Report, |
124 | 120 | $url, |
125 | 121 | self::createHeadersFor(HttpMethods::Report, [$depth]), |
@@ -132,9 +128,8 @@ discard block |
||
132 | 128 | * @param string $etag |
133 | 129 | * @return Request |
134 | 130 | */ |
135 | - public static function createDeleteRequest($url , $etag){ |
|
136 | - return new Request |
|
137 | - ( |
|
131 | + public static function createDeleteRequest($url, $etag) { |
|
132 | + return new Request( |
|
138 | 133 | HttpMethods::Delete, |
139 | 134 | $url, |
140 | 135 | self::createHeadersFor(HttpMethods::Delete, [$etag]) |
@@ -145,9 +140,8 @@ discard block |
||
145 | 140 | * @param string $url |
146 | 141 | * @return Request |
147 | 142 | */ |
148 | - public static function createGetRequest($url){ |
|
149 | - return new Request |
|
150 | - ( |
|
143 | + public static function createGetRequest($url) { |
|
144 | + return new Request( |
|
151 | 145 | HttpMethods::Get, |
152 | 146 | $url, |
153 | 147 | self::createHeadersFor(HttpMethods::Get) |
@@ -160,10 +154,9 @@ discard block |
||
160 | 154 | * @param string $etag |
161 | 155 | * @return Request |
162 | 156 | */ |
163 | - public static function createPutRequest($url, $body, $etag = null){ |
|
157 | + public static function createPutRequest($url, $body, $etag = null) { |
|
164 | 158 | |
165 | - return new Request |
|
166 | - ( |
|
159 | + return new Request( |
|
167 | 160 | HttpMethods::Put, |
168 | 161 | $url, |
169 | 162 | self::createHeadersFor(HttpMethods::Put, [strlen($body), $etag]), |
@@ -177,9 +170,8 @@ discard block |
||
177 | 170 | * @param string $etag |
178 | 171 | * @return Request |
179 | 172 | */ |
180 | - public static function createPostRequest($url, $body, $etag = null){ |
|
181 | - return new Request |
|
182 | - ( |
|
173 | + public static function createPostRequest($url, $body, $etag = null) { |
|
174 | + return new Request( |
|
183 | 175 | HttpMethods::Post, |
184 | 176 | $url, |
185 | 177 | self::createHeadersFor(HttpMethods::Post, [$etag]), |
@@ -22,11 +22,11 @@ |
||
22 | 22 | * @return string |
23 | 23 | */ |
24 | 24 | public function getPrincipalUrl() { |
25 | - $url = isset($this->found_props['current-user-principal']) && isset($this->found_props['current-user-principal']['href']) ? |
|
25 | + $url = isset($this->found_props['current-user-principal']) && isset($this->found_props['current-user-principal']['href']) ? |
|
26 | 26 | $this->server_url.$this->found_props['current-user-principal']['href'] : null; |
27 | 27 | // check on not found one ( issue on caldav icloud imp) |
28 | - if(empty($url)) |
|
29 | - $url = isset($this->not_found_props['current-user-principal']) && isset($this->not_found_props['current-user-principal']['href']) ? |
|
28 | + if (empty($url)) |
|
29 | + $url = isset($this->not_found_props['current-user-principal']) && isset($this->not_found_props['current-user-principal']['href']) ? |
|
30 | 30 | $this->server_url.$this->not_found_props['current-user-principal']['href'] : null; |
31 | 31 | return $url; |
32 | 32 | } |
@@ -25,9 +25,10 @@ |
||
25 | 25 | $url = isset($this->found_props['current-user-principal']) && isset($this->found_props['current-user-principal']['href']) ? |
26 | 26 | $this->server_url.$this->found_props['current-user-principal']['href'] : null; |
27 | 27 | // check on not found one ( issue on caldav icloud imp) |
28 | - if(empty($url)) |
|
29 | - $url = isset($this->not_found_props['current-user-principal']) && isset($this->not_found_props['current-user-principal']['href']) ? |
|
28 | + if(empty($url)) { |
|
29 | + $url = isset($this->not_found_props['current-user-principal']) && isset($this->not_found_props['current-user-principal']['href']) ? |
|
30 | 30 | $this->server_url.$this->not_found_props['current-user-principal']['href'] : null; |
31 | + } |
|
31 | 32 | return $url; |
32 | 33 | } |
33 | 34 | } |
34 | 35 | \ No newline at end of file |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * @return string |
23 | 23 | */ |
24 | - public function getETag(){ |
|
24 | + public function getETag() { |
|
25 | 25 | return isset($this->found_props['getetag']) ? $this->found_props['getetag'] : null; |
26 | 26 | } |
27 | 27 | |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function getStatus() |
32 | 32 | { |
33 | - if(isset($this->content['response']['status'])) return $this->content['response']['status']; |
|
34 | - if(isset($this->content['response']['propstat']['status'])) return $this->content['response']['propstat']['status']; |
|
33 | + if (isset($this->content['response']['status'])) return $this->content['response']['status']; |
|
34 | + if (isset($this->content['response']['propstat']['status'])) return $this->content['response']['propstat']['status']; |
|
35 | 35 | |
36 | 36 | return null; |
37 | 37 | } |
@@ -30,8 +30,12 @@ |
||
30 | 30 | */ |
31 | 31 | public function getStatus() |
32 | 32 | { |
33 | - if(isset($this->content['response']['status'])) return $this->content['response']['status']; |
|
34 | - if(isset($this->content['response']['propstat']['status'])) return $this->content['response']['propstat']['status']; |
|
33 | + if(isset($this->content['response']['status'])) { |
|
34 | + return $this->content['response']['status']; |
|
35 | + } |
|
36 | + if(isset($this->content['response']['propstat']['status'])) { |
|
37 | + return $this->content['response']['propstat']['status']; |
|
38 | + } |
|
35 | 39 | |
36 | 40 | return null; |
37 | 41 | } |