diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-12-07 15:28:06 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-01-12 14:24:47 +0100 |
commit | 1a20af253bc90de35a1bf3b65adb33ab44d17c1d (patch) | |
tree | 77a6f2181318cdffb85f97cdbcbf75bf40e3aa35 /apps/dav/lib/carddav/syncservice.php | |
parent | 0bf026cceab5f5e910f5e7c163397dbe76dbe0f2 (diff) | |
download | nextcloud-server-1a20af253bc90de35a1bf3b65adb33ab44d17c1d.tar.gz nextcloud-server-1a20af253bc90de35a1bf3b65adb33ab44d17c1d.zip |
Adding tests and adjust PHPDoc
Diffstat (limited to 'apps/dav/lib/carddav/syncservice.php')
-rw-r--r-- | apps/dav/lib/carddav/syncservice.php | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/apps/dav/lib/carddav/syncservice.php b/apps/dav/lib/carddav/syncservice.php index 8442f7cf52b..bfaf09f4c0e 100644 --- a/apps/dav/lib/carddav/syncservice.php +++ b/apps/dav/lib/carddav/syncservice.php @@ -34,6 +34,16 @@ class SyncService { $this->backend = $backend; } + /** + * @param string $url + * @param string $userName + * @param string $sharedSecret + * @param string $syncToken + * @param int $targetBookId + * @param string $targetPrincipal + * @param array $targetProperties + * @return string + */ public function syncRemoteAddressBook($url, $userName, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetProperties) { // 1. create addressbook $book = $this->ensureSystemAddressBookExists($targetPrincipal, $targetBookId, $targetProperties); @@ -62,6 +72,13 @@ class SyncService { return $response['token']; } + /** + * @param string $principal + * @param string $id + * @param array $properties + * @return array|null + * @throws \Sabre\DAV\Exception\BadRequest + */ protected function ensureSystemAddressBookExists($principal, $id, $properties) { $book = $this->backend->getAddressBooksByUri($id); if (!is_null($book)) { @@ -104,7 +121,13 @@ class SyncService { return $result; } - private function download($url, $sharedSecret, $changeSet) { + /** + * @param string $url + * @param string $sharedSecret + * @param string $resourcePath + * @return array + */ + private function download($url, $sharedSecret, $resourcePath) { $settings = [ 'baseUri' => $url, 'userName' => 'system', @@ -113,11 +136,15 @@ class SyncService { $client = new Client($settings); $client->setThrowExceptions(true); - $response = $client->request('GET', $changeSet); + $response = $client->request('GET', $resourcePath); return $response; } - function buildSyncCollectionRequestBody($synToken) { + /** + * @param string|null $synToken + * @return string + */ + private function buildSyncCollectionRequestBody($synToken) { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->formatOutput = true; @@ -137,6 +164,11 @@ class SyncService { return $body; } + /** + * @param string $body + * @return array + * @throws \Sabre\Xml\ParseException + */ private function parseMultiStatus($body) { $xml = new Service(); |