Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/contacts.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormatt <34400929+call-me-matt@users.noreply.github.com>2020-09-09 17:45:56 +0300
committercall-me-matt <nextcloud@matthiasheinisch.de>2020-09-09 18:06:59 +0300
commitc03bd908b6df2018b54fc6cdbdd90dca922e1c10 (patch)
tree8499fa72f2496ef50a95586d525ab4d774dbed83 /lib
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')
-rw-r--r--lib/Cron/SocialUpdate.php2
-rw-r--r--lib/Service/SocialApiService.php26
2 files changed, 11 insertions, 17 deletions
diff --git a/lib/Cron/SocialUpdate.php b/lib/Cron/SocialUpdate.php
index 46621e25..fcb41a5c 100644
--- a/lib/Cron/SocialUpdate.php
+++ b/lib/Cron/SocialUpdate.php
@@ -48,7 +48,7 @@ class SocialUpdate extends \OC\BackgroundJob\QueuedJob {
// update contacts with first available social media profile
$result = $this->social->updateAddressbooks('any', $userId, $offsetBook, $offsetContact);
- if ($result->getStatus() == Http::STATUS_PARTIAL_CONTENT) {
+ if ($result->getStatus() === Http::STATUS_PARTIAL_CONTENT) {
// not finished; schedule a follow-up
$report = $result->getData();
$stoppedAtBook = $report[0]['stoppedAt']['addressBook'];
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);
}
/**