(string $method, string $url, $body = null, array $headers = [])
| 476 | } |
| 477 | |
| 478 | private function request(string $method, string $url, $body = null, array $headers = []): int |
| 479 | { |
| 480 | try { |
| 481 | $resp = $this->client->request($method, $url, $body, $headers); |
| 482 | $status = (int)($resp['statusCode'] ?? 0); |
| 483 | if ($status < 200 || $status >= 300) { |
| 484 | $msg = trim((string)($resp['body'] ?? '')); |
| 485 | if ($msg !== '') { |
| 486 | $msg = preg_replace('/\\s+/', ' ', $msg); |
| 487 | if (strlen($msg) > 240) { |
| 488 | $msg = substr($msg, 0, 240) . '...'; |
| 489 | } |
| 490 | } |
| 491 | $this->lastError = $msg !== '' ? ('HTTP ' . $status . ': ' . $msg) : ('HTTP ' . $status); |
| 492 | } else { |
| 493 | $this->lastError = ''; |
| 494 | } |
| 495 | return $status; |
| 496 | } catch (Throwable $e) { |
| 497 | $msg = trim($e->getMessage()); |
| 498 | if ($msg !== '') { |
| 499 | $msg = preg_replace('/(https?:\\/\\/)([^\\s@]+@)/i', '$1', $msg); |
| 500 | $this->lastError = $msg; |
| 501 | } else { |
| 502 | $this->lastError = 'WebDAV request failed'; |
| 503 | } |
| 504 | return 0; |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | private function isCollection($value): bool |
| 509 | { |
no outgoing calls
no test coverage detected