summaryrefslogtreecommitdiffstats
path: root/lib/Service
diff options
context:
space:
mode:
authormatt <34400929+call-me-matt@users.noreply.github.com>2020-09-09 16:45:56 +0200
committercall-me-matt <nextcloud@matthiasheinisch.de>2020-09-09 17:06:59 +0200
commitc03bd908b6df2018b54fc6cdbdd90dca922e1c10 (patch)
tree8499fa72f2496ef50a95586d525ab4d774dbed83 /lib/Service
parentba67a50ecedc7dfa9eba36992726504c0e6d39bc (diff)
Apply suggestions from code review
add elegance from nickvergessen Co-authored-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com> Signed-off-by: call-me-matt <nextcloud@matthiasheinisch.de>
Diffstat (limited to 'lib/Service')
-rw-r--r--lib/Service/SocialApiService.php26
1 files changed, 10 insertions, 16 deletions
diff --git a/lib/Service/SocialApiService.php b/lib/Service/SocialApiService.php
index 290200c2..8594ba68 100644
--- a/lib/Service/SocialApiService.php
+++ b/lib/Service/SocialApiService.php
@@ -131,9 +131,9 @@ class SocialApiService {
*
* @returns {IAddressBook} the corresponding addressbook or null
*/
- protected function getAddressBook(string $addressbookId, $manager=false) : ?IAddressBook {
+ protected function getAddressBook(string $addressbookId, IManager $manager = null) : ?IAddressBook {
$addressBook = null;
- if ($manager == false) {
+ if ($manager === null) {
$manager = $this->manager;
}
$addressBooks = $manager->getUserAddressBooks();
@@ -223,27 +223,24 @@ class SocialApiService {
*
* @returns {bool} true if the addressbook exists
*/
- public function existsAddressBook($searchBookId, $userId) {
+ public function existsAddressBook(string $searchBookId, string $userId): bool {
$manager = $this->manager;
$coma = new ContactsManager($this->davBackend, $this->l10n);
$coma->setupContactsProvider($manager, $userId, $this->urlGen);
$addressBooks = $manager->getUserAddressBooks();
- if ($this->getAddressBook($searchBookId, $manager) == null) {
- return false;
- }
- return true;
+ return $this->getAddressBook($searchBookId, $manager) !== null;
}
/**
* checks a contact exists in an addressbook
*
- * @param {string} searchContactId the UID of the contact to verify
- * @param {string} searchBookId the UID of the addressbook to look in
- * @param {string} userId the user that should have access
+ * @param string searchContactId the UID of the contact to verify
+ * @param string searchBookId the UID of the addressbook to look in
+ * @param string userId the user that should have access
*
- * @returns {bool} true if the contact exists
+ * @returns bool true if the contact exists
*/
- public function existsContact($searchContactId, $searchBookId, $userId) {
+ public function existsContact(string $searchContactId, string $searchBookId, string $userId): bool {
// load address books for the user
$manager = $this->manager;
$coma = new ContactsManager($this->davBackend, $this->l10n);
@@ -254,10 +251,7 @@ class SocialApiService {
}
$check = $addressBook->search($searchContactId, ['UID'], ['types' => true]);
- if (empty($check)) {
- return false;
- }
- return true;
+ return !empty($check);
}
/**