diff options
author | Georg Ehrke <developer@georgehrke.com> | 2019-08-02 16:34:39 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-08-15 20:02:56 +0200 |
commit | 11fa45196ec5229e640a4e27569f94929510d7da (patch) | |
tree | c063123fef07b265242e2caf6cf7f7073054af8a /apps/dav/lib | |
parent | 36b9b51297165afcb9071d72f83cf431b01b4edd (diff) | |
download | nextcloud-server-11fa45196ec5229e640a4e27569f94929510d7da.tar.gz nextcloud-server-11fa45196ec5229e640a4e27569f94929510d7da.zip |
smaller syntax changes to CalDAV reminder classes
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
Diffstat (limited to 'apps/dav/lib')
7 files changed, 38 insertions, 56 deletions
diff --git a/apps/dav/lib/CalDAV/Reminder/AbstractNotificationProvider.php b/apps/dav/lib/CalDAV/Reminder/AbstractNotificationProvider.php index ba928fac80f..1d858627de9 100644 --- a/apps/dav/lib/CalDAV/Reminder/AbstractNotificationProvider.php +++ b/apps/dav/lib/CalDAV/Reminder/AbstractNotificationProvider.php @@ -37,9 +37,9 @@ use Sabre\VObject\DateTimeParser; use Sabre\VObject\Parameter; use Sabre\VObject\Property; -abstract class AbstractNotificationProvider -{ +abstract class AbstractNotificationProvider { + /** @var string */ public const NOTIFICATION_TYPE = ''; /** @var ILogger */ @@ -78,7 +78,7 @@ abstract class AbstractNotificationProvider * @param IUser $user * @return void */ - public function send(VCalendar $vcalendar, string $calendarDisplayName, IUser $user): void {} + abstract function send(VCalendar $vcalendar, string $calendarDisplayName, IUser $user): void; /** * @var VCalendar $vcalendar @@ -86,8 +86,7 @@ abstract class AbstractNotificationProvider * @return array * @throws \Exception */ - protected function extractEventDetails(VCalendar $vcalendar, $defaultValue = ''): array - { + protected function extractEventDetails(VCalendar $vcalendar, $defaultValue = ''):array { /** @var VEvent $vevent */ $vevent = $vcalendar->VEVENT; @@ -129,8 +128,7 @@ abstract class AbstractNotificationProvider * @return string * @throws \Exception */ - private function generateWhenString(Property $dtstart, Property $dtend): string - { + private function generateWhenString(Property $dtstart, Property $dtend):string { $isAllDay = $dtstart instanceof Property\ICalendar\Date; /** @var Property\ICalendar\Date | Property\ICalendar\DateTime $dtstart */ @@ -201,8 +199,7 @@ abstract class AbstractNotificationProvider * @param DateTime $dtEnd * @return bool */ - private function isDayEqual(DateTime $dtStart, DateTime $dtEnd): bool - { + private function isDayEqual(DateTime $dtStart, DateTime $dtEnd):bool { return $dtStart->format('Y-m-d') === $dtEnd->format('Y-m-d'); } } diff --git a/apps/dav/lib/CalDAV/Reminder/Backend.php b/apps/dav/lib/CalDAV/Reminder/Backend.php index c85e7c365dc..087a5785f36 100644 --- a/apps/dav/lib/CalDAV/Reminder/Backend.php +++ b/apps/dav/lib/CalDAV/Reminder/Backend.php @@ -56,8 +56,7 @@ class Backend { * @param int $notificationDate * @param int $eventStartDate */ - public function insertReminder(string $uid, string $calendarId, string $uri, string $type, int $notificationDate, int $eventStartDate): void - { + public function insertReminder(string $uid, string $calendarId, string $uri, string $type, int $notificationDate, int $eventStartDate):void { $query = $this->db->getQueryBuilder(); $query->insert('calendar_reminders') ->values([ @@ -76,8 +75,7 @@ class Backend { * @param int $calendarId * @param string $objectUri */ - public function cleanRemindersForEvent(int $calendarId, string $objectUri): void - { + public function cleanRemindersForEvent(int $calendarId, string $objectUri):void { $query = $this->db->getQueryBuilder(); $query->delete('calendar_reminders') @@ -92,8 +90,7 @@ class Backend { * @param integer $calendarId * @return void */ - public function cleanRemindersForCalendar(int $calendarId): void - { + public function cleanRemindersForCalendar(int $calendarId):void { $query = $this->db->getQueryBuilder(); $query->delete('calendar_reminders') @@ -107,8 +104,7 @@ class Backend { * @param integer $reminderId * @return void */ - public function removeReminder(int $reminderId): void - { + public function removeReminder(int $reminderId):void { $query = $this->db->getQueryBuilder(); $query->delete('calendar_reminders') @@ -122,8 +118,7 @@ class Backend { * @return array * @throws \Exception */ - public function getRemindersToProcess(): array - { + public function getRemindersToProcess():array { $query = $this->db->getQueryBuilder(); $fields = ['cr.id', 'cr.calendarid', 'cr.objecturi', 'cr.type', 'cr.notificationdate', 'cr.uid', 'co.calendardata', 'c.displayname']; $stmt = $query->select($fields) diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php index 81d4474011c..f05439932b6 100644 --- a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php +++ b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php @@ -33,11 +33,12 @@ use OCP\Mail\IMailer; use OCP\IUser; use Sabre\VObject\Component\VCalendar; -class EmailProvider extends AbstractNotificationProvider -{ +class EmailProvider extends AbstractNotificationProvider { + /** @var IMailer */ private $mailer; + /** @var string */ public const NOTIFICATION_TYPE = 'EMAIL'; /** @@ -63,8 +64,7 @@ class EmailProvider extends AbstractNotificationProvider * @return void * @throws \Exception */ - public function send(VCalendar $vcalendar, string $calendarDisplayName, IUser $user): void - { + public function send(VCalendar $vcalendar, string $calendarDisplayName, IUser $user):void { if ($user->getEMailAddress() === null) { return; } @@ -111,8 +111,7 @@ class EmailProvider extends AbstractNotificationProvider * @param IEMailTemplate $template * @param string $summary */ - private function addSubjectAndHeading(IEMailTemplate $template, string $summary): void - { + private function addSubjectAndHeading(IEMailTemplate $template, string $summary):void { $template->setSubject('Notification: ' . $summary); $template->addHeading($summary); } @@ -122,8 +121,7 @@ class EmailProvider extends AbstractNotificationProvider * @param array $eventData * @param string $calendarDisplayName */ - private function addBulletList(IEMailTemplate $template, array $eventData, string $calendarDisplayName): void - { + private function addBulletList(IEMailTemplate $template, array $eventData, string $calendarDisplayName):void { $template->addBodyListItem($calendarDisplayName, $this->l10n->t('Calendar:'), $this->getAbsoluteImagePath('actions/info.svg')); @@ -148,8 +146,7 @@ class EmailProvider extends AbstractNotificationProvider * @param string $path * @return string */ - private function getAbsoluteImagePath($path): string - { + private function getAbsoluteImagePath(string $path):string { return $this->urlGenerator->getAbsoluteURL( $this->urlGenerator->imagePath('core', $path) ); diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php index 1bb0e5c68b1..f04b8e4c45a 100644 --- a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php +++ b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php @@ -35,9 +35,9 @@ use OCP\Notification\INotification; use Sabre\VObject\Component\VCalendar; use OCP\AppFramework\Utility\ITimeFactory; -class PushProvider extends AbstractNotificationProvider -{ +class PushProvider extends AbstractNotificationProvider { + /** @var string */ public const NOTIFICATION_TYPE = 'DISPLAY'; /** @@ -75,9 +75,7 @@ class PushProvider extends AbstractNotificationProvider * @return void * @throws \Exception */ - public function send(VCalendar $vcalendar, string $calendarDisplayName, IUser $user): void - { - + public function send(VCalendar $vcalendar, string $calendarDisplayName, IUser $user):void { $lang = $this->config->getUserValue($user->getUID(), 'core', 'lang', $this->l10nFactory->findLanguage()); $this->l10n = $this->l10nFactory->get('dav', $lang); diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php b/apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php index 389cbbd2bfa..0a2579aedfb 100644 --- a/apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php +++ b/apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php @@ -31,8 +31,7 @@ class NotificationProviderManager { * @throws ProviderNotAvailableException * @throws NotificationTypeDoesNotExistException */ - public function getProvider(string $type): AbstractNotificationProvider - { + public function getProvider(string $type):AbstractNotificationProvider { if (in_array($type, ReminderService::REMINDER_TYPES, true)) { if (isset($this->providers[$type])) { return $this->providers[$type]; @@ -46,8 +45,7 @@ class NotificationProviderManager { * @param string $providerClassName * @throws \OCP\AppFramework\QueryException */ - public function registerProvider(string $providerClassName): void - { + public function registerProvider(string $providerClassName):void { $provider = \OC::$server->query($providerClassName); if (!$provider instanceof AbstractNotificationProvider) { diff --git a/apps/dav/lib/CalDAV/Reminder/Notifier.php b/apps/dav/lib/CalDAV/Reminder/Notifier.php index d95774e019e..ff34208a794 100644 --- a/apps/dav/lib/CalDAV/Reminder/Notifier.php +++ b/apps/dav/lib/CalDAV/Reminder/Notifier.php @@ -31,14 +31,15 @@ use OCP\IURLGenerator; class Notifier implements INotifier { - public static $units = array( + /** @var array */ + public static $units = [ 'y' => 'year', 'm' => 'month', 'd' => 'day', 'h' => 'hour', 'i' => 'minute', 's' => 'second', - ); + ]; /** @var IFactory */ protected $factory; @@ -60,8 +61,7 @@ class Notifier implements INotifier { * @return INotification * @throws \Exception */ - public function prepare(INotification $notification, $languageCode): INotification - { + public function prepare(INotification $notification, string $languageCode):INotification { if ($notification->getApp() !== Application::APP_ID) { throw new \InvalidArgumentException('Notification not from this app'); } @@ -87,8 +87,7 @@ class Notifier implements INotifier { * @return string * @throws \Exception */ - private function processEventTitle(array $event): string - { + private function processEventTitle(array $event):string { $event_datetime = new \DateTime(); $event_datetime->setTimestamp($event['start']); $now = new \DateTime(); @@ -112,8 +111,7 @@ class Notifier implements INotifier { * @param string $title * @return string */ - private function getPluralizedTitle(int $count, int $invert, string $unit, string $title): string - { + private function getPluralizedTitle(int $count, int $invert, string $unit, string $title):string { if ($invert) { return $this->l->n('%s (in one %s)', '%s (in %n %ss)', $count, [$title, $unit]); } @@ -125,8 +123,7 @@ class Notifier implements INotifier { * @param array $event * @return string */ - private function processEventDescription(array $event): string - { + private function processEventDescription(array $event):string { $description = [ $this->l->t('Calendar: %s', $event['calendar']), $this->l->t('Date: %s', $event['when']), diff --git a/apps/dav/lib/CalDAV/Reminder/ReminderService.php b/apps/dav/lib/CalDAV/Reminder/ReminderService.php index 87c2ce10673..ce6c846061e 100644 --- a/apps/dav/lib/CalDAV/Reminder/ReminderService.php +++ b/apps/dav/lib/CalDAV/Reminder/ReminderService.php @@ -49,7 +49,11 @@ class ReminderService { public const REMINDER_TYPE_DISPLAY = 'DISPLAY'; public const REMINDER_TYPE_AUDIO = 'AUDIO'; - public const REMINDER_TYPES = [self::REMINDER_TYPE_EMAIL, self::REMINDER_TYPE_DISPLAY, self::REMINDER_TYPE_AUDIO]; + public const REMINDER_TYPES = [ + self::REMINDER_TYPE_EMAIL, + self::REMINDER_TYPE_DISPLAY, + self::REMINDER_TYPE_AUDIO + ]; public function __construct(Backend $backend, NotificationProviderManager $notificationProviderManager, @@ -70,9 +74,7 @@ class ReminderService { * @throws NotificationProvider\ProviderNotAvailableException * @throws NotificationTypeDoesNotExistException */ - public function processReminders(): void - { - + public function processReminders():void { $reminders = $this->backend->getRemindersToProcess(); foreach ($reminders as $reminder) { @@ -101,8 +103,7 @@ class ReminderService { * @throws VObject\InvalidDataException * @throws NoUserException */ - public function onTouchCalendarObject(string $action, array $calendarData, array $shares, array $objectData): void - { + public function onTouchCalendarObject(string $action, array $calendarData, array $shares, array $objectData):void { if (!isset($calendarData['principaluri'])) { return; } @@ -157,8 +158,7 @@ class ReminderService { * @param array $shares * @return string[] */ - private function getUsersForShares(array $shares): array - { + private function getUsersForShares(array $shares):array { $users = $groups = []; foreach ($shares as $share) { $principal = explode('/', $share['{http://owncloud.org/ns}principal']); |