Passed
Push — master ( a78624...b981cb )
by Christoph
14:14 queued 11s
created
apps/updatenotification/lib/Notification/Notifier.php 1 patch
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -39,161 +39,161 @@
 block discarded – undo
39 39
 
40 40
 class Notifier implements INotifier {
41 41
 
42
-	/** @var IURLGenerator */
43
-	protected $url;
44
-
45
-	/** @var IConfig */
46
-	protected $config;
47
-
48
-	/** @var IManager */
49
-	protected $notificationManager;
50
-
51
-	/** @var IFactory */
52
-	protected $l10NFactory;
53
-
54
-	/** @var IUserSession */
55
-	protected $userSession;
56
-
57
-	/** @var IGroupManager */
58
-	protected $groupManager;
59
-
60
-	/** @var string[] */
61
-	protected $appVersions;
62
-
63
-	/**
64
-	 * Notifier constructor.
65
-	 *
66
-	 * @param IURLGenerator $url
67
-	 * @param IConfig $config
68
-	 * @param IManager $notificationManager
69
-	 * @param IFactory $l10NFactory
70
-	 * @param IUserSession $userSession
71
-	 * @param IGroupManager $groupManager
72
-	 */
73
-	public function __construct(IURLGenerator $url, IConfig $config, IManager $notificationManager, IFactory $l10NFactory, IUserSession $userSession, IGroupManager $groupManager) {
74
-		$this->url = $url;
75
-		$this->notificationManager = $notificationManager;
76
-		$this->config = $config;
77
-		$this->l10NFactory = $l10NFactory;
78
-		$this->userSession = $userSession;
79
-		$this->groupManager = $groupManager;
80
-		$this->appVersions = $this->getAppVersions();
81
-	}
82
-
83
-	/**
84
-	 * Identifier of the notifier, only use [a-z0-9_]
85
-	 *
86
-	 * @return string
87
-	 * @since 17.0.0
88
-	 */
89
-	public function getID(): string {
90
-		return 'updatenotification';
91
-	}
92
-
93
-	/**
94
-	 * Human readable name describing the notifier
95
-	 *
96
-	 * @return string
97
-	 * @since 17.0.0
98
-	 */
99
-	public function getName(): string {
100
-		return $this->l10NFactory->get('updatenotification')->t('Update notifications');
101
-	}
102
-
103
-	/**
104
-	 * @param INotification $notification
105
-	 * @param string $languageCode The code of the language that should be used to prepare the notification
106
-	 * @return INotification
107
-	 * @throws \InvalidArgumentException When the notification was not prepared by a notifier
108
-	 * @throws AlreadyProcessedException When the notification is not needed anymore and should be deleted
109
-	 * @since 9.0.0
110
-	 */
111
-	public function prepare(INotification $notification, string $languageCode): INotification {
112
-		if ($notification->getApp() !== 'updatenotification') {
113
-			throw new \InvalidArgumentException('Unknown app id');
114
-		}
115
-
116
-		$l = $this->l10NFactory->get('updatenotification', $languageCode);
117
-		if ($notification->getSubject() === 'connection_error') {
118
-			$errors = (int) $this->config->getAppValue('updatenotification', 'update_check_errors', 0);
119
-			if ($errors === 0) {
120
-				$this->notificationManager->markProcessed($notification);
121
-				throw new \InvalidArgumentException('Update checked worked again');
122
-			}
123
-
124
-			$notification->setParsedSubject($l->t('The update server could not be reached since %d days to check for new updates.', [$errors]))
125
-				->setParsedMessage($l->t('Please check the Nextcloud and server log files for errors.'));
126
-		} elseif ($notification->getObjectType() === 'core') {
127
-			$this->updateAlreadyInstalledCheck($notification, $this->getCoreVersions());
128
-
129
-			$parameters = $notification->getSubjectParameters();
130
-			$notification->setParsedSubject($l->t('Update to %1$s is available.', [$parameters['version']]));
131
-
132
-			if ($this->isAdmin()) {
133
-				$notification->setLink($this->url->linkToRouteAbsolute('settings.AdminSettings.index', ['section' => 'overview']) . '#version');
134
-			}
135
-		} else {
136
-			$appInfo = $this->getAppInfo($notification->getObjectType());
137
-			$appName = ($appInfo === null) ? $notification->getObjectType() : $appInfo['name'];
138
-
139
-			if (isset($this->appVersions[$notification->getObjectType()])) {
140
-				$this->updateAlreadyInstalledCheck($notification, $this->appVersions[$notification->getObjectType()]);
141
-			}
142
-
143
-			$notification->setParsedSubject($l->t('Update for %1$s to version %2$s is available.', [$appName, $notification->getObjectId()]))
144
-				->setRichSubject($l->t('Update for {app} to version %s is available.', [$notification->getObjectId()]), [
145
-					'app' => [
146
-						'type' => 'app',
147
-						'id' => $notification->getObjectType(),
148
-						'name' => $appName,
149
-					]
150
-				]);
151
-
152
-			if ($this->isAdmin()) {
153
-				$notification->setLink($this->url->linkToRouteAbsolute('settings.AppSettings.viewApps', ['category' => 'updates']) . '#app-' . $notification->getObjectType());
154
-			}
155
-		}
156
-
157
-		$notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('updatenotification', 'notification.svg')));
158
-
159
-		return $notification;
160
-	}
161
-
162
-	/**
163
-	 * Remove the notification and prevent rendering, when the update is installed
164
-	 *
165
-	 * @param INotification $notification
166
-	 * @param string $installedVersion
167
-	 * @throws AlreadyProcessedException When the update is already installed
168
-	 */
169
-	protected function updateAlreadyInstalledCheck(INotification $notification, $installedVersion) {
170
-		if (version_compare($notification->getObjectId(), $installedVersion, '<=')) {
171
-			throw new AlreadyProcessedException();
172
-		}
173
-	}
174
-
175
-	/**
176
-	 * @return bool
177
-	 */
178
-	protected function isAdmin(): bool {
179
-		$user = $this->userSession->getUser();
180
-
181
-		if ($user instanceof IUser) {
182
-			return $this->groupManager->isAdmin($user->getUID());
183
-		}
184
-
185
-		return false;
186
-	}
187
-
188
-	protected function getCoreVersions(): string {
189
-		return implode('.', Util::getVersion());
190
-	}
191
-
192
-	protected function getAppVersions(): array {
193
-		return \OC_App::getAppVersions();
194
-	}
195
-
196
-	protected function getAppInfo($appId) {
197
-		return \OC_App::getAppInfo($appId);
198
-	}
42
+    /** @var IURLGenerator */
43
+    protected $url;
44
+
45
+    /** @var IConfig */
46
+    protected $config;
47
+
48
+    /** @var IManager */
49
+    protected $notificationManager;
50
+
51
+    /** @var IFactory */
52
+    protected $l10NFactory;
53
+
54
+    /** @var IUserSession */
55
+    protected $userSession;
56
+
57
+    /** @var IGroupManager */
58
+    protected $groupManager;
59
+
60
+    /** @var string[] */
61
+    protected $appVersions;
62
+
63
+    /**
64
+     * Notifier constructor.
65
+     *
66
+     * @param IURLGenerator $url
67
+     * @param IConfig $config
68
+     * @param IManager $notificationManager
69
+     * @param IFactory $l10NFactory
70
+     * @param IUserSession $userSession
71
+     * @param IGroupManager $groupManager
72
+     */
73
+    public function __construct(IURLGenerator $url, IConfig $config, IManager $notificationManager, IFactory $l10NFactory, IUserSession $userSession, IGroupManager $groupManager) {
74
+        $this->url = $url;
75
+        $this->notificationManager = $notificationManager;
76
+        $this->config = $config;
77
+        $this->l10NFactory = $l10NFactory;
78
+        $this->userSession = $userSession;
79
+        $this->groupManager = $groupManager;
80
+        $this->appVersions = $this->getAppVersions();
81
+    }
82
+
83
+    /**
84
+     * Identifier of the notifier, only use [a-z0-9_]
85
+     *
86
+     * @return string
87
+     * @since 17.0.0
88
+     */
89
+    public function getID(): string {
90
+        return 'updatenotification';
91
+    }
92
+
93
+    /**
94
+     * Human readable name describing the notifier
95
+     *
96
+     * @return string
97
+     * @since 17.0.0
98
+     */
99
+    public function getName(): string {
100
+        return $this->l10NFactory->get('updatenotification')->t('Update notifications');
101
+    }
102
+
103
+    /**
104
+     * @param INotification $notification
105
+     * @param string $languageCode The code of the language that should be used to prepare the notification
106
+     * @return INotification
107
+     * @throws \InvalidArgumentException When the notification was not prepared by a notifier
108
+     * @throws AlreadyProcessedException When the notification is not needed anymore and should be deleted
109
+     * @since 9.0.0
110
+     */
111
+    public function prepare(INotification $notification, string $languageCode): INotification {
112
+        if ($notification->getApp() !== 'updatenotification') {
113
+            throw new \InvalidArgumentException('Unknown app id');
114
+        }
115
+
116
+        $l = $this->l10NFactory->get('updatenotification', $languageCode);
117
+        if ($notification->getSubject() === 'connection_error') {
118
+            $errors = (int) $this->config->getAppValue('updatenotification', 'update_check_errors', 0);
119
+            if ($errors === 0) {
120
+                $this->notificationManager->markProcessed($notification);
121
+                throw new \InvalidArgumentException('Update checked worked again');
122
+            }
123
+
124
+            $notification->setParsedSubject($l->t('The update server could not be reached since %d days to check for new updates.', [$errors]))
125
+                ->setParsedMessage($l->t('Please check the Nextcloud and server log files for errors.'));
126
+        } elseif ($notification->getObjectType() === 'core') {
127
+            $this->updateAlreadyInstalledCheck($notification, $this->getCoreVersions());
128
+
129
+            $parameters = $notification->getSubjectParameters();
130
+            $notification->setParsedSubject($l->t('Update to %1$s is available.', [$parameters['version']]));
131
+
132
+            if ($this->isAdmin()) {
133
+                $notification->setLink($this->url->linkToRouteAbsolute('settings.AdminSettings.index', ['section' => 'overview']) . '#version');
134
+            }
135
+        } else {
136
+            $appInfo = $this->getAppInfo($notification->getObjectType());
137
+            $appName = ($appInfo === null) ? $notification->getObjectType() : $appInfo['name'];
138
+
139
+            if (isset($this->appVersions[$notification->getObjectType()])) {
140
+                $this->updateAlreadyInstalledCheck($notification, $this->appVersions[$notification->getObjectType()]);
141
+            }
142
+
143
+            $notification->setParsedSubject($l->t('Update for %1$s to version %2$s is available.', [$appName, $notification->getObjectId()]))
144
+                ->setRichSubject($l->t('Update for {app} to version %s is available.', [$notification->getObjectId()]), [
145
+                    'app' => [
146
+                        'type' => 'app',
147
+                        'id' => $notification->getObjectType(),
148
+                        'name' => $appName,
149
+                    ]
150
+                ]);
151
+
152
+            if ($this->isAdmin()) {
153
+                $notification->setLink($this->url->linkToRouteAbsolute('settings.AppSettings.viewApps', ['category' => 'updates']) . '#app-' . $notification->getObjectType());
154
+            }
155
+        }
156
+
157
+        $notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('updatenotification', 'notification.svg')));
158
+
159
+        return $notification;
160
+    }
161
+
162
+    /**
163
+     * Remove the notification and prevent rendering, when the update is installed
164
+     *
165
+     * @param INotification $notification
166
+     * @param string $installedVersion
167
+     * @throws AlreadyProcessedException When the update is already installed
168
+     */
169
+    protected function updateAlreadyInstalledCheck(INotification $notification, $installedVersion) {
170
+        if (version_compare($notification->getObjectId(), $installedVersion, '<=')) {
171
+            throw new AlreadyProcessedException();
172
+        }
173
+    }
174
+
175
+    /**
176
+     * @return bool
177
+     */
178
+    protected function isAdmin(): bool {
179
+        $user = $this->userSession->getUser();
180
+
181
+        if ($user instanceof IUser) {
182
+            return $this->groupManager->isAdmin($user->getUID());
183
+        }
184
+
185
+        return false;
186
+    }
187
+
188
+    protected function getCoreVersions(): string {
189
+        return implode('.', Util::getVersion());
190
+    }
191
+
192
+    protected function getAppVersions(): array {
193
+        return \OC_App::getAppVersions();
194
+    }
195
+
196
+    protected function getAppInfo($appId) {
197
+        return \OC_App::getAppInfo($appId);
198
+    }
199 199
 }
Please login to merge, or discard this patch.
lib/private/Authentication/Notifications/Notifier.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -32,65 +32,65 @@
 block discarded – undo
32 32
 
33 33
 class Notifier implements INotifier {
34 34
 
35
-	/** @var IL10nFactory */
36
-	private $factory;
35
+    /** @var IL10nFactory */
36
+    private $factory;
37 37
 
38
-	public function __construct(IL10nFactory $l10nFactory) {
39
-		$this->factory = $l10nFactory;
40
-	}
38
+    public function __construct(IL10nFactory $l10nFactory) {
39
+        $this->factory = $l10nFactory;
40
+    }
41 41
 
42
-	/**
43
-	 * @inheritDoc
44
-	 */
45
-	public function prepare(INotification $notification, string $languageCode): INotification {
46
-		if ($notification->getApp() !== 'auth') {
47
-			// Not my app => throw
48
-			throw new InvalidArgumentException();
49
-		}
42
+    /**
43
+     * @inheritDoc
44
+     */
45
+    public function prepare(INotification $notification, string $languageCode): INotification {
46
+        if ($notification->getApp() !== 'auth') {
47
+            // Not my app => throw
48
+            throw new InvalidArgumentException();
49
+        }
50 50
 
51
-		// Read the language from the notification
52
-		$l = $this->factory->get('lib', $languageCode);
51
+        // Read the language from the notification
52
+        $l = $this->factory->get('lib', $languageCode);
53 53
 
54
-		switch ($notification->getSubject()) {
55
-			case 'remote_wipe_start':
56
-				$notification->setParsedSubject(
57
-					$l->t('Remote wipe started')
58
-				)->setParsedMessage(
59
-					$l->t('A remote wipe was started on device %s', $notification->getSubjectParameters())
60
-				);
54
+        switch ($notification->getSubject()) {
55
+            case 'remote_wipe_start':
56
+                $notification->setParsedSubject(
57
+                    $l->t('Remote wipe started')
58
+                )->setParsedMessage(
59
+                    $l->t('A remote wipe was started on device %s', $notification->getSubjectParameters())
60
+                );
61 61
 
62
-				return $notification;
63
-			case 'remote_wipe_finish':
64
-				$notification->setParsedSubject(
65
-					$l->t('Remote wipe finished')
66
-				)->setParsedMessage(
67
-					$l->t('The remote wipe on %s has finished', $notification->getSubjectParameters())
68
-				);
62
+                return $notification;
63
+            case 'remote_wipe_finish':
64
+                $notification->setParsedSubject(
65
+                    $l->t('Remote wipe finished')
66
+                )->setParsedMessage(
67
+                    $l->t('The remote wipe on %s has finished', $notification->getSubjectParameters())
68
+                );
69 69
 
70
-				return $notification;
71
-			default:
72
-				// Unknown subject => Unknown notification => throw
73
-				throw new InvalidArgumentException();
74
-		}
75
-	}
70
+                return $notification;
71
+            default:
72
+                // Unknown subject => Unknown notification => throw
73
+                throw new InvalidArgumentException();
74
+        }
75
+    }
76 76
 
77
-	/**
78
-	 * Identifier of the notifier, only use [a-z0-9_]
79
-	 *
80
-	 * @return string
81
-	 * @since 17.0.0
82
-	 */
83
-	public function getID(): string {
84
-		return 'auth';
85
-	}
77
+    /**
78
+     * Identifier of the notifier, only use [a-z0-9_]
79
+     *
80
+     * @return string
81
+     * @since 17.0.0
82
+     */
83
+    public function getID(): string {
84
+        return 'auth';
85
+    }
86 86
 
87
-	/**
88
-	 * Human readable name describing the notifier
89
-	 *
90
-	 * @return string
91
-	 * @since 17.0.0
92
-	 */
93
-	public function getName(): string {
94
-		return $this->factory->get('lib')->t('Authentication');
95
-	}
87
+    /**
88
+     * Human readable name describing the notifier
89
+     *
90
+     * @return string
91
+     * @since 17.0.0
92
+     */
93
+    public function getName(): string {
94
+        return $this->factory->get('lib')->t('Authentication');
95
+    }
96 96
 }
Please login to merge, or discard this patch.
lib/private/Notification/Notification.php 1 patch
Indentation   +543 added lines, -543 removed lines patch added patch discarded remove patch
@@ -33,547 +33,547 @@
 block discarded – undo
33 33
 
34 34
 class Notification implements INotification {
35 35
 
36
-	/** @var IValidator */
37
-	protected $richValidator;
38
-
39
-	/** @var string */
40
-	protected $app;
41
-
42
-	/** @var string */
43
-	protected $user;
44
-
45
-	/** @var \DateTime */
46
-	protected $dateTime;
47
-
48
-	/** @var string */
49
-	protected $objectType;
50
-
51
-	/** @var string */
52
-	protected $objectId;
53
-
54
-	/** @var string */
55
-	protected $subject;
56
-
57
-	/** @var array */
58
-	protected $subjectParameters;
59
-
60
-	/** @var string */
61
-	protected $subjectParsed;
62
-
63
-	/** @var string */
64
-	protected $subjectRich;
65
-
66
-	/** @var array */
67
-	protected $subjectRichParameters;
68
-
69
-	/** @var string */
70
-	protected $message;
71
-
72
-	/** @var array */
73
-	protected $messageParameters;
74
-
75
-	/** @var string */
76
-	protected $messageParsed;
77
-
78
-	/** @var string */
79
-	protected $messageRich;
80
-
81
-	/** @var array */
82
-	protected $messageRichParameters;
83
-
84
-	/** @var string */
85
-	protected $link;
86
-
87
-	/** @var string */
88
-	protected $icon;
89
-
90
-	/** @var array */
91
-	protected $actions;
92
-
93
-	/** @var array */
94
-	protected $actionsParsed;
95
-
96
-	/** @var bool */
97
-	protected $hasPrimaryAction;
98
-
99
-	/** @var bool */
100
-	protected $hasPrimaryParsedAction;
101
-
102
-	public function __construct(IValidator $richValidator) {
103
-		$this->richValidator = $richValidator;
104
-		$this->app = '';
105
-		$this->user = '';
106
-		$this->dateTime = new \DateTime();
107
-		$this->dateTime->setTimestamp(0);
108
-		$this->objectType = '';
109
-		$this->objectId = '';
110
-		$this->subject = '';
111
-		$this->subjectParameters = [];
112
-		$this->subjectParsed = '';
113
-		$this->subjectRich = '';
114
-		$this->subjectRichParameters = [];
115
-		$this->message = '';
116
-		$this->messageParameters = [];
117
-		$this->messageParsed = '';
118
-		$this->messageRich = '';
119
-		$this->messageRichParameters = [];
120
-		$this->link = '';
121
-		$this->icon = '';
122
-		$this->actions = [];
123
-		$this->actionsParsed = [];
124
-	}
125
-
126
-	/**
127
-	 * @param string $app
128
-	 * @return $this
129
-	 * @throws \InvalidArgumentException if the app id is invalid
130
-	 * @since 8.2.0
131
-	 */
132
-	public function setApp(string $app): INotification {
133
-		if ($app === '' || isset($app[32])) {
134
-			throw new \InvalidArgumentException('The given app name is invalid');
135
-		}
136
-		$this->app = $app;
137
-		return $this;
138
-	}
139
-
140
-	/**
141
-	 * @return string
142
-	 * @since 8.2.0
143
-	 */
144
-	public function getApp(): string {
145
-		return $this->app;
146
-	}
147
-
148
-	/**
149
-	 * @param string $user
150
-	 * @return $this
151
-	 * @throws \InvalidArgumentException if the user id is invalid
152
-	 * @since 8.2.0
153
-	 */
154
-	public function setUser(string $user): INotification {
155
-		if ($user === '' || isset($user[64])) {
156
-			throw new \InvalidArgumentException('The given user id is invalid');
157
-		}
158
-		$this->user = $user;
159
-		return $this;
160
-	}
161
-
162
-	/**
163
-	 * @return string
164
-	 * @since 8.2.0
165
-	 */
166
-	public function getUser(): string {
167
-		return $this->user;
168
-	}
169
-
170
-	/**
171
-	 * @param \DateTime $dateTime
172
-	 * @return $this
173
-	 * @throws \InvalidArgumentException if the $dateTime is invalid
174
-	 * @since 9.0.0
175
-	 */
176
-	public function setDateTime(\DateTime $dateTime): INotification {
177
-		if ($dateTime->getTimestamp() === 0) {
178
-			throw new \InvalidArgumentException('The given date time is invalid');
179
-		}
180
-		$this->dateTime = $dateTime;
181
-		return $this;
182
-	}
183
-
184
-	/**
185
-	 * @return \DateTime
186
-	 * @since 9.0.0
187
-	 */
188
-	public function getDateTime(): \DateTime {
189
-		return $this->dateTime;
190
-	}
191
-
192
-	/**
193
-	 * @param string $type
194
-	 * @param string $id
195
-	 * @return $this
196
-	 * @throws \InvalidArgumentException if the object type or id is invalid
197
-	 * @since 8.2.0 - 9.0.0: Type of $id changed to string
198
-	 */
199
-	public function setObject(string $type, string $id): INotification {
200
-		if ($type === '' || isset($type[64])) {
201
-			throw new \InvalidArgumentException('The given object type is invalid');
202
-		}
203
-		$this->objectType = $type;
204
-
205
-		if ($id === '' || isset($id[64])) {
206
-			throw new \InvalidArgumentException('The given object id is invalid');
207
-		}
208
-		$this->objectId = (string) $id;
209
-		return $this;
210
-	}
211
-
212
-	/**
213
-	 * @return string
214
-	 * @since 8.2.0
215
-	 */
216
-	public function getObjectType(): string {
217
-		return $this->objectType;
218
-	}
219
-
220
-	/**
221
-	 * @return string
222
-	 * @since 8.2.0 - 9.0.0: Return type changed to string
223
-	 */
224
-	public function getObjectId(): string {
225
-		return $this->objectId;
226
-	}
227
-
228
-	/**
229
-	 * @param string $subject
230
-	 * @param array $parameters
231
-	 * @return $this
232
-	 * @throws \InvalidArgumentException if the subject or parameters are invalid
233
-	 * @since 8.2.0
234
-	 */
235
-	public function setSubject(string $subject, array $parameters = []): INotification {
236
-		if ($subject === '' || isset($subject[64])) {
237
-			throw new \InvalidArgumentException('The given subject is invalid');
238
-		}
239
-
240
-		$this->subject = $subject;
241
-		$this->subjectParameters = $parameters;
242
-
243
-		return $this;
244
-	}
245
-
246
-	/**
247
-	 * @return string
248
-	 * @since 8.2.0
249
-	 */
250
-	public function getSubject(): string {
251
-		return $this->subject;
252
-	}
253
-
254
-	/**
255
-	 * @return array
256
-	 * @since 8.2.0
257
-	 */
258
-	public function getSubjectParameters(): array {
259
-		return $this->subjectParameters;
260
-	}
261
-
262
-	/**
263
-	 * @param string $subject
264
-	 * @return $this
265
-	 * @throws \InvalidArgumentException if the subject is invalid
266
-	 * @since 8.2.0
267
-	 */
268
-	public function setParsedSubject(string $subject): INotification {
269
-		if ($subject === '') {
270
-			throw new \InvalidArgumentException('The given parsed subject is invalid');
271
-		}
272
-		$this->subjectParsed = $subject;
273
-		return $this;
274
-	}
275
-
276
-	/**
277
-	 * @return string
278
-	 * @since 8.2.0
279
-	 */
280
-	public function getParsedSubject(): string {
281
-		return $this->subjectParsed;
282
-	}
283
-
284
-	/**
285
-	 * @param string $subject
286
-	 * @param array $parameters
287
-	 * @return $this
288
-	 * @throws \InvalidArgumentException if the subject or parameters are invalid
289
-	 * @since 11.0.0
290
-	 */
291
-	public function setRichSubject(string $subject, array $parameters = []): INotification {
292
-		if ($subject === '') {
293
-			throw new \InvalidArgumentException('The given parsed subject is invalid');
294
-		}
295
-
296
-		$this->subjectRich = $subject;
297
-		$this->subjectRichParameters = $parameters;
298
-
299
-		return $this;
300
-	}
301
-
302
-	/**
303
-	 * @return string
304
-	 * @since 11.0.0
305
-	 */
306
-	public function getRichSubject(): string {
307
-		return $this->subjectRich;
308
-	}
309
-
310
-	/**
311
-	 * @return array[]
312
-	 * @since 11.0.0
313
-	 */
314
-	public function getRichSubjectParameters(): array {
315
-		return $this->subjectRichParameters;
316
-	}
317
-
318
-	/**
319
-	 * @param string $message
320
-	 * @param array $parameters
321
-	 * @return $this
322
-	 * @throws \InvalidArgumentException if the message or parameters are invalid
323
-	 * @since 8.2.0
324
-	 */
325
-	public function setMessage(string $message, array $parameters = []): INotification {
326
-		if ($message === '' || isset($message[64])) {
327
-			throw new \InvalidArgumentException('The given message is invalid');
328
-		}
329
-
330
-		$this->message = $message;
331
-		$this->messageParameters = $parameters;
332
-
333
-		return $this;
334
-	}
335
-
336
-	/**
337
-	 * @return string
338
-	 * @since 8.2.0
339
-	 */
340
-	public function getMessage(): string {
341
-		return $this->message;
342
-	}
343
-
344
-	/**
345
-	 * @return array
346
-	 * @since 8.2.0
347
-	 */
348
-	public function getMessageParameters(): array {
349
-		return $this->messageParameters;
350
-	}
351
-
352
-	/**
353
-	 * @param string $message
354
-	 * @return $this
355
-	 * @throws \InvalidArgumentException if the message is invalid
356
-	 * @since 8.2.0
357
-	 */
358
-	public function setParsedMessage(string $message): INotification {
359
-		if ($message === '') {
360
-			throw new \InvalidArgumentException('The given parsed message is invalid');
361
-		}
362
-		$this->messageParsed = $message;
363
-		return $this;
364
-	}
365
-
366
-	/**
367
-	 * @return string
368
-	 * @since 8.2.0
369
-	 */
370
-	public function getParsedMessage(): string {
371
-		return $this->messageParsed;
372
-	}
373
-
374
-	/**
375
-	 * @param string $message
376
-	 * @param array $parameters
377
-	 * @return $this
378
-	 * @throws \InvalidArgumentException if the message or parameters are invalid
379
-	 * @since 11.0.0
380
-	 */
381
-	public function setRichMessage(string $message, array $parameters = []): INotification {
382
-		if ($message === '') {
383
-			throw new \InvalidArgumentException('The given parsed message is invalid');
384
-		}
385
-
386
-		$this->messageRich = $message;
387
-		$this->messageRichParameters = $parameters;
388
-
389
-		return $this;
390
-	}
391
-
392
-	/**
393
-	 * @return string
394
-	 * @since 11.0.0
395
-	 */
396
-	public function getRichMessage(): string {
397
-		return $this->messageRich;
398
-	}
399
-
400
-	/**
401
-	 * @return array[]
402
-	 * @since 11.0.0
403
-	 */
404
-	public function getRichMessageParameters(): array {
405
-		return $this->messageRichParameters;
406
-	}
407
-
408
-	/**
409
-	 * @param string $link
410
-	 * @return $this
411
-	 * @throws \InvalidArgumentException if the link is invalid
412
-	 * @since 8.2.0
413
-	 */
414
-	public function setLink(string $link): INotification {
415
-		if ($link === '' || isset($link[4000])) {
416
-			throw new \InvalidArgumentException('The given link is invalid');
417
-		}
418
-		$this->link = $link;
419
-		return $this;
420
-	}
421
-
422
-	/**
423
-	 * @return string
424
-	 * @since 8.2.0
425
-	 */
426
-	public function getLink(): string {
427
-		return $this->link;
428
-	}
429
-
430
-	/**
431
-	 * @param string $icon
432
-	 * @return $this
433
-	 * @throws \InvalidArgumentException if the icon is invalid
434
-	 * @since 11.0.0
435
-	 */
436
-	public function setIcon(string $icon): INotification {
437
-		if ($icon === '' || isset($icon[4000])) {
438
-			throw new \InvalidArgumentException('The given icon is invalid');
439
-		}
440
-		$this->icon = $icon;
441
-		return $this;
442
-	}
443
-
444
-	/**
445
-	 * @return string
446
-	 * @since 11.0.0
447
-	 */
448
-	public function getIcon(): string {
449
-		return $this->icon;
450
-	}
451
-
452
-	/**
453
-	 * @return IAction
454
-	 * @since 8.2.0
455
-	 */
456
-	public function createAction(): IAction {
457
-		return new Action();
458
-	}
459
-
460
-	/**
461
-	 * @param IAction $action
462
-	 * @return $this
463
-	 * @throws \InvalidArgumentException if the action is invalid
464
-	 * @since 8.2.0
465
-	 */
466
-	public function addAction(IAction $action): INotification {
467
-		if (!$action->isValid()) {
468
-			throw new \InvalidArgumentException('The given action is invalid');
469
-		}
470
-
471
-		if ($action->isPrimary()) {
472
-			if ($this->hasPrimaryAction) {
473
-				throw new \InvalidArgumentException('The notification already has a primary action');
474
-			}
475
-
476
-			$this->hasPrimaryAction = true;
477
-		}
478
-
479
-		$this->actions[] = $action;
480
-		return $this;
481
-	}
482
-
483
-	/**
484
-	 * @return IAction[]
485
-	 * @since 8.2.0
486
-	 */
487
-	public function getActions(): array {
488
-		return $this->actions;
489
-	}
490
-
491
-	/**
492
-	 * @param IAction $action
493
-	 * @return $this
494
-	 * @throws \InvalidArgumentException if the action is invalid
495
-	 * @since 8.2.0
496
-	 */
497
-	public function addParsedAction(IAction $action): INotification {
498
-		if (!$action->isValidParsed()) {
499
-			throw new \InvalidArgumentException('The given parsed action is invalid');
500
-		}
501
-
502
-		if ($action->isPrimary()) {
503
-			if ($this->hasPrimaryParsedAction) {
504
-				throw new \InvalidArgumentException('The notification already has a primary action');
505
-			}
506
-
507
-			$this->hasPrimaryParsedAction = true;
508
-
509
-			// Make sure the primary action is always the first one
510
-			array_unshift($this->actionsParsed, $action);
511
-		} else {
512
-			$this->actionsParsed[] = $action;
513
-		}
514
-
515
-		return $this;
516
-	}
517
-
518
-	/**
519
-	 * @return IAction[]
520
-	 * @since 8.2.0
521
-	 */
522
-	public function getParsedActions(): array {
523
-		return $this->actionsParsed;
524
-	}
525
-
526
-	/**
527
-	 * @return bool
528
-	 * @since 8.2.0
529
-	 */
530
-	public function isValid(): bool {
531
-		return
532
-			$this->isValidCommon()
533
-			&&
534
-			$this->getSubject() !== ''
535
-		;
536
-	}
537
-
538
-	/**
539
-	 * @return bool
540
-	 * @since 8.2.0
541
-	 */
542
-	public function isValidParsed(): bool {
543
-		if ($this->getRichSubject() !== '' || !empty($this->getRichSubjectParameters())) {
544
-			try {
545
-				$this->richValidator->validate($this->getRichSubject(), $this->getRichSubjectParameters());
546
-			} catch (InvalidObjectExeption $e) {
547
-				return false;
548
-			}
549
-		}
550
-
551
-		if ($this->getRichMessage() !== '' || !empty($this->getRichMessageParameters())) {
552
-			try {
553
-				$this->richValidator->validate($this->getRichMessage(), $this->getRichMessageParameters());
554
-			} catch (InvalidObjectExeption $e) {
555
-				return false;
556
-			}
557
-		}
558
-
559
-		return
560
-			$this->isValidCommon()
561
-			&&
562
-			$this->getParsedSubject() !== ''
563
-		;
564
-	}
565
-
566
-	protected function isValidCommon(): bool {
567
-		return
568
-			$this->getApp() !== ''
569
-			&&
570
-			$this->getUser() !== ''
571
-			&&
572
-			$this->getDateTime()->getTimestamp() !== 0
573
-			&&
574
-			$this->getObjectType() !== ''
575
-			&&
576
-			$this->getObjectId() !== ''
577
-		;
578
-	}
36
+    /** @var IValidator */
37
+    protected $richValidator;
38
+
39
+    /** @var string */
40
+    protected $app;
41
+
42
+    /** @var string */
43
+    protected $user;
44
+
45
+    /** @var \DateTime */
46
+    protected $dateTime;
47
+
48
+    /** @var string */
49
+    protected $objectType;
50
+
51
+    /** @var string */
52
+    protected $objectId;
53
+
54
+    /** @var string */
55
+    protected $subject;
56
+
57
+    /** @var array */
58
+    protected $subjectParameters;
59
+
60
+    /** @var string */
61
+    protected $subjectParsed;
62
+
63
+    /** @var string */
64
+    protected $subjectRich;
65
+
66
+    /** @var array */
67
+    protected $subjectRichParameters;
68
+
69
+    /** @var string */
70
+    protected $message;
71
+
72
+    /** @var array */
73
+    protected $messageParameters;
74
+
75
+    /** @var string */
76
+    protected $messageParsed;
77
+
78
+    /** @var string */
79
+    protected $messageRich;
80
+
81
+    /** @var array */
82
+    protected $messageRichParameters;
83
+
84
+    /** @var string */
85
+    protected $link;
86
+
87
+    /** @var string */
88
+    protected $icon;
89
+
90
+    /** @var array */
91
+    protected $actions;
92
+
93
+    /** @var array */
94
+    protected $actionsParsed;
95
+
96
+    /** @var bool */
97
+    protected $hasPrimaryAction;
98
+
99
+    /** @var bool */
100
+    protected $hasPrimaryParsedAction;
101
+
102
+    public function __construct(IValidator $richValidator) {
103
+        $this->richValidator = $richValidator;
104
+        $this->app = '';
105
+        $this->user = '';
106
+        $this->dateTime = new \DateTime();
107
+        $this->dateTime->setTimestamp(0);
108
+        $this->objectType = '';
109
+        $this->objectId = '';
110
+        $this->subject = '';
111
+        $this->subjectParameters = [];
112
+        $this->subjectParsed = '';
113
+        $this->subjectRich = '';
114
+        $this->subjectRichParameters = [];
115
+        $this->message = '';
116
+        $this->messageParameters = [];
117
+        $this->messageParsed = '';
118
+        $this->messageRich = '';
119
+        $this->messageRichParameters = [];
120
+        $this->link = '';
121
+        $this->icon = '';
122
+        $this->actions = [];
123
+        $this->actionsParsed = [];
124
+    }
125
+
126
+    /**
127
+     * @param string $app
128
+     * @return $this
129
+     * @throws \InvalidArgumentException if the app id is invalid
130
+     * @since 8.2.0
131
+     */
132
+    public function setApp(string $app): INotification {
133
+        if ($app === '' || isset($app[32])) {
134
+            throw new \InvalidArgumentException('The given app name is invalid');
135
+        }
136
+        $this->app = $app;
137
+        return $this;
138
+    }
139
+
140
+    /**
141
+     * @return string
142
+     * @since 8.2.0
143
+     */
144
+    public function getApp(): string {
145
+        return $this->app;
146
+    }
147
+
148
+    /**
149
+     * @param string $user
150
+     * @return $this
151
+     * @throws \InvalidArgumentException if the user id is invalid
152
+     * @since 8.2.0
153
+     */
154
+    public function setUser(string $user): INotification {
155
+        if ($user === '' || isset($user[64])) {
156
+            throw new \InvalidArgumentException('The given user id is invalid');
157
+        }
158
+        $this->user = $user;
159
+        return $this;
160
+    }
161
+
162
+    /**
163
+     * @return string
164
+     * @since 8.2.0
165
+     */
166
+    public function getUser(): string {
167
+        return $this->user;
168
+    }
169
+
170
+    /**
171
+     * @param \DateTime $dateTime
172
+     * @return $this
173
+     * @throws \InvalidArgumentException if the $dateTime is invalid
174
+     * @since 9.0.0
175
+     */
176
+    public function setDateTime(\DateTime $dateTime): INotification {
177
+        if ($dateTime->getTimestamp() === 0) {
178
+            throw new \InvalidArgumentException('The given date time is invalid');
179
+        }
180
+        $this->dateTime = $dateTime;
181
+        return $this;
182
+    }
183
+
184
+    /**
185
+     * @return \DateTime
186
+     * @since 9.0.0
187
+     */
188
+    public function getDateTime(): \DateTime {
189
+        return $this->dateTime;
190
+    }
191
+
192
+    /**
193
+     * @param string $type
194
+     * @param string $id
195
+     * @return $this
196
+     * @throws \InvalidArgumentException if the object type or id is invalid
197
+     * @since 8.2.0 - 9.0.0: Type of $id changed to string
198
+     */
199
+    public function setObject(string $type, string $id): INotification {
200
+        if ($type === '' || isset($type[64])) {
201
+            throw new \InvalidArgumentException('The given object type is invalid');
202
+        }
203
+        $this->objectType = $type;
204
+
205
+        if ($id === '' || isset($id[64])) {
206
+            throw new \InvalidArgumentException('The given object id is invalid');
207
+        }
208
+        $this->objectId = (string) $id;
209
+        return $this;
210
+    }
211
+
212
+    /**
213
+     * @return string
214
+     * @since 8.2.0
215
+     */
216
+    public function getObjectType(): string {
217
+        return $this->objectType;
218
+    }
219
+
220
+    /**
221
+     * @return string
222
+     * @since 8.2.0 - 9.0.0: Return type changed to string
223
+     */
224
+    public function getObjectId(): string {
225
+        return $this->objectId;
226
+    }
227
+
228
+    /**
229
+     * @param string $subject
230
+     * @param array $parameters
231
+     * @return $this
232
+     * @throws \InvalidArgumentException if the subject or parameters are invalid
233
+     * @since 8.2.0
234
+     */
235
+    public function setSubject(string $subject, array $parameters = []): INotification {
236
+        if ($subject === '' || isset($subject[64])) {
237
+            throw new \InvalidArgumentException('The given subject is invalid');
238
+        }
239
+
240
+        $this->subject = $subject;
241
+        $this->subjectParameters = $parameters;
242
+
243
+        return $this;
244
+    }
245
+
246
+    /**
247
+     * @return string
248
+     * @since 8.2.0
249
+     */
250
+    public function getSubject(): string {
251
+        return $this->subject;
252
+    }
253
+
254
+    /**
255
+     * @return array
256
+     * @since 8.2.0
257
+     */
258
+    public function getSubjectParameters(): array {
259
+        return $this->subjectParameters;
260
+    }
261
+
262
+    /**
263
+     * @param string $subject
264
+     * @return $this
265
+     * @throws \InvalidArgumentException if the subject is invalid
266
+     * @since 8.2.0
267
+     */
268
+    public function setParsedSubject(string $subject): INotification {
269
+        if ($subject === '') {
270
+            throw new \InvalidArgumentException('The given parsed subject is invalid');
271
+        }
272
+        $this->subjectParsed = $subject;
273
+        return $this;
274
+    }
275
+
276
+    /**
277
+     * @return string
278
+     * @since 8.2.0
279
+     */
280
+    public function getParsedSubject(): string {
281
+        return $this->subjectParsed;
282
+    }
283
+
284
+    /**
285
+     * @param string $subject
286
+     * @param array $parameters
287
+     * @return $this
288
+     * @throws \InvalidArgumentException if the subject or parameters are invalid
289
+     * @since 11.0.0
290
+     */
291
+    public function setRichSubject(string $subject, array $parameters = []): INotification {
292
+        if ($subject === '') {
293
+            throw new \InvalidArgumentException('The given parsed subject is invalid');
294
+        }
295
+
296
+        $this->subjectRich = $subject;
297
+        $this->subjectRichParameters = $parameters;
298
+
299
+        return $this;
300
+    }
301
+
302
+    /**
303
+     * @return string
304
+     * @since 11.0.0
305
+     */
306
+    public function getRichSubject(): string {
307
+        return $this->subjectRich;
308
+    }
309
+
310
+    /**
311
+     * @return array[]
312
+     * @since 11.0.0
313
+     */
314
+    public function getRichSubjectParameters(): array {
315
+        return $this->subjectRichParameters;
316
+    }
317
+
318
+    /**
319
+     * @param string $message
320
+     * @param array $parameters
321
+     * @return $this
322
+     * @throws \InvalidArgumentException if the message or parameters are invalid
323
+     * @since 8.2.0
324
+     */
325
+    public function setMessage(string $message, array $parameters = []): INotification {
326
+        if ($message === '' || isset($message[64])) {
327
+            throw new \InvalidArgumentException('The given message is invalid');
328
+        }
329
+
330
+        $this->message = $message;
331
+        $this->messageParameters = $parameters;
332
+
333
+        return $this;
334
+    }
335
+
336
+    /**
337
+     * @return string
338
+     * @since 8.2.0
339
+     */
340
+    public function getMessage(): string {
341
+        return $this->message;
342
+    }
343
+
344
+    /**
345
+     * @return array
346
+     * @since 8.2.0
347
+     */
348
+    public function getMessageParameters(): array {
349
+        return $this->messageParameters;
350
+    }
351
+
352
+    /**
353
+     * @param string $message
354
+     * @return $this
355
+     * @throws \InvalidArgumentException if the message is invalid
356
+     * @since 8.2.0
357
+     */
358
+    public function setParsedMessage(string $message): INotification {
359
+        if ($message === '') {
360
+            throw new \InvalidArgumentException('The given parsed message is invalid');
361
+        }
362
+        $this->messageParsed = $message;
363
+        return $this;
364
+    }
365
+
366
+    /**
367
+     * @return string
368
+     * @since 8.2.0
369
+     */
370
+    public function getParsedMessage(): string {
371
+        return $this->messageParsed;
372
+    }
373
+
374
+    /**
375
+     * @param string $message
376
+     * @param array $parameters
377
+     * @return $this
378
+     * @throws \InvalidArgumentException if the message or parameters are invalid
379
+     * @since 11.0.0
380
+     */
381
+    public function setRichMessage(string $message, array $parameters = []): INotification {
382
+        if ($message === '') {
383
+            throw new \InvalidArgumentException('The given parsed message is invalid');
384
+        }
385
+
386
+        $this->messageRich = $message;
387
+        $this->messageRichParameters = $parameters;
388
+
389
+        return $this;
390
+    }
391
+
392
+    /**
393
+     * @return string
394
+     * @since 11.0.0
395
+     */
396
+    public function getRichMessage(): string {
397
+        return $this->messageRich;
398
+    }
399
+
400
+    /**
401
+     * @return array[]
402
+     * @since 11.0.0
403
+     */
404
+    public function getRichMessageParameters(): array {
405
+        return $this->messageRichParameters;
406
+    }
407
+
408
+    /**
409
+     * @param string $link
410
+     * @return $this
411
+     * @throws \InvalidArgumentException if the link is invalid
412
+     * @since 8.2.0
413
+     */
414
+    public function setLink(string $link): INotification {
415
+        if ($link === '' || isset($link[4000])) {
416
+            throw new \InvalidArgumentException('The given link is invalid');
417
+        }
418
+        $this->link = $link;
419
+        return $this;
420
+    }
421
+
422
+    /**
423
+     * @return string
424
+     * @since 8.2.0
425
+     */
426
+    public function getLink(): string {
427
+        return $this->link;
428
+    }
429
+
430
+    /**
431
+     * @param string $icon
432
+     * @return $this
433
+     * @throws \InvalidArgumentException if the icon is invalid
434
+     * @since 11.0.0
435
+     */
436
+    public function setIcon(string $icon): INotification {
437
+        if ($icon === '' || isset($icon[4000])) {
438
+            throw new \InvalidArgumentException('The given icon is invalid');
439
+        }
440
+        $this->icon = $icon;
441
+        return $this;
442
+    }
443
+
444
+    /**
445
+     * @return string
446
+     * @since 11.0.0
447
+     */
448
+    public function getIcon(): string {
449
+        return $this->icon;
450
+    }
451
+
452
+    /**
453
+     * @return IAction
454
+     * @since 8.2.0
455
+     */
456
+    public function createAction(): IAction {
457
+        return new Action();
458
+    }
459
+
460
+    /**
461
+     * @param IAction $action
462
+     * @return $this
463
+     * @throws \InvalidArgumentException if the action is invalid
464
+     * @since 8.2.0
465
+     */
466
+    public function addAction(IAction $action): INotification {
467
+        if (!$action->isValid()) {
468
+            throw new \InvalidArgumentException('The given action is invalid');
469
+        }
470
+
471
+        if ($action->isPrimary()) {
472
+            if ($this->hasPrimaryAction) {
473
+                throw new \InvalidArgumentException('The notification already has a primary action');
474
+            }
475
+
476
+            $this->hasPrimaryAction = true;
477
+        }
478
+
479
+        $this->actions[] = $action;
480
+        return $this;
481
+    }
482
+
483
+    /**
484
+     * @return IAction[]
485
+     * @since 8.2.0
486
+     */
487
+    public function getActions(): array {
488
+        return $this->actions;
489
+    }
490
+
491
+    /**
492
+     * @param IAction $action
493
+     * @return $this
494
+     * @throws \InvalidArgumentException if the action is invalid
495
+     * @since 8.2.0
496
+     */
497
+    public function addParsedAction(IAction $action): INotification {
498
+        if (!$action->isValidParsed()) {
499
+            throw new \InvalidArgumentException('The given parsed action is invalid');
500
+        }
501
+
502
+        if ($action->isPrimary()) {
503
+            if ($this->hasPrimaryParsedAction) {
504
+                throw new \InvalidArgumentException('The notification already has a primary action');
505
+            }
506
+
507
+            $this->hasPrimaryParsedAction = true;
508
+
509
+            // Make sure the primary action is always the first one
510
+            array_unshift($this->actionsParsed, $action);
511
+        } else {
512
+            $this->actionsParsed[] = $action;
513
+        }
514
+
515
+        return $this;
516
+    }
517
+
518
+    /**
519
+     * @return IAction[]
520
+     * @since 8.2.0
521
+     */
522
+    public function getParsedActions(): array {
523
+        return $this->actionsParsed;
524
+    }
525
+
526
+    /**
527
+     * @return bool
528
+     * @since 8.2.0
529
+     */
530
+    public function isValid(): bool {
531
+        return
532
+            $this->isValidCommon()
533
+            &&
534
+            $this->getSubject() !== ''
535
+        ;
536
+    }
537
+
538
+    /**
539
+     * @return bool
540
+     * @since 8.2.0
541
+     */
542
+    public function isValidParsed(): bool {
543
+        if ($this->getRichSubject() !== '' || !empty($this->getRichSubjectParameters())) {
544
+            try {
545
+                $this->richValidator->validate($this->getRichSubject(), $this->getRichSubjectParameters());
546
+            } catch (InvalidObjectExeption $e) {
547
+                return false;
548
+            }
549
+        }
550
+
551
+        if ($this->getRichMessage() !== '' || !empty($this->getRichMessageParameters())) {
552
+            try {
553
+                $this->richValidator->validate($this->getRichMessage(), $this->getRichMessageParameters());
554
+            } catch (InvalidObjectExeption $e) {
555
+                return false;
556
+            }
557
+        }
558
+
559
+        return
560
+            $this->isValidCommon()
561
+            &&
562
+            $this->getParsedSubject() !== ''
563
+        ;
564
+    }
565
+
566
+    protected function isValidCommon(): bool {
567
+        return
568
+            $this->getApp() !== ''
569
+            &&
570
+            $this->getUser() !== ''
571
+            &&
572
+            $this->getDateTime()->getTimestamp() !== 0
573
+            &&
574
+            $this->getObjectType() !== ''
575
+            &&
576
+            $this->getObjectId() !== ''
577
+        ;
578
+    }
579 579
 }
Please login to merge, or discard this patch.
lib/private/Notification/Action.php 1 patch
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -28,146 +28,146 @@
 block discarded – undo
28 28
 
29 29
 class Action implements IAction {
30 30
 
31
-	/** @var string */
32
-	protected $label;
33
-
34
-	/** @var string */
35
-	protected $labelParsed;
36
-
37
-	/** @var string */
38
-	protected $link;
39
-
40
-	/** @var string */
41
-	protected $requestType;
42
-
43
-	/** @var string */
44
-	protected $icon;
45
-
46
-	/** @var bool */
47
-	protected $primary;
48
-
49
-	public function __construct() {
50
-		$this->label = '';
51
-		$this->labelParsed = '';
52
-		$this->link = '';
53
-		$this->requestType = '';
54
-		$this->primary = false;
55
-	}
56
-
57
-	/**
58
-	 * @param string $label
59
-	 * @return $this
60
-	 * @throws \InvalidArgumentException if the label is invalid
61
-	 * @since 8.2.0
62
-	 */
63
-	public function setLabel(string $label): IAction {
64
-		if ($label === '' || isset($label[32])) {
65
-			throw new \InvalidArgumentException('The given label is invalid');
66
-		}
67
-		$this->label = $label;
68
-		return $this;
69
-	}
70
-
71
-	/**
72
-	 * @return string
73
-	 * @since 8.2.0
74
-	 */
75
-	public function getLabel(): string {
76
-		return $this->label;
77
-	}
78
-
79
-	/**
80
-	 * @param string $label
81
-	 * @return $this
82
-	 * @throws \InvalidArgumentException if the label is invalid
83
-	 * @since 8.2.0
84
-	 */
85
-	public function setParsedLabel(string $label): IAction {
86
-		if ($label === '') {
87
-			throw new \InvalidArgumentException('The given parsed label is invalid');
88
-		}
89
-		$this->labelParsed = $label;
90
-		return $this;
91
-	}
92
-
93
-	/**
94
-	 * @return string
95
-	 * @since 8.2.0
96
-	 */
97
-	public function getParsedLabel(): string {
98
-		return $this->labelParsed;
99
-	}
100
-
101
-	/**
102
-	 * @param $primary bool
103
-	 * @return $this
104
-	 * @since 9.0.0
105
-	 */
106
-	public function setPrimary(bool $primary): IAction {
107
-		$this->primary = $primary;
108
-		return $this;
109
-	}
110
-
111
-	/**
112
-	 * @return bool
113
-	 * @since 9.0.0
114
-	 */
115
-	public function isPrimary(): bool {
116
-		return $this->primary;
117
-	}
118
-
119
-	/**
120
-	 * @param string $link
121
-	 * @param string $requestType
122
-	 * @return $this
123
-	 * @throws \InvalidArgumentException if the link is invalid
124
-	 * @since 8.2.0
125
-	 */
126
-	public function setLink(string $link, string $requestType): IAction {
127
-		if ($link === '' || isset($link[256])) {
128
-			throw new \InvalidArgumentException('The given link is invalid');
129
-		}
130
-		if (!in_array($requestType, [
131
-			self::TYPE_GET,
132
-			self::TYPE_POST,
133
-			self::TYPE_PUT,
134
-			self::TYPE_DELETE,
135
-			self::TYPE_WEB,
136
-		], true)) {
137
-			throw new \InvalidArgumentException('The given request type is invalid');
138
-		}
139
-		$this->link = $link;
140
-		$this->requestType = $requestType;
141
-		return $this;
142
-	}
143
-
144
-	/**
145
-	 * @return string
146
-	 * @since 8.2.0
147
-	 */
148
-	public function getLink(): string {
149
-		return $this->link;
150
-	}
151
-
152
-	/**
153
-	 * @return string
154
-	 * @since 8.2.0
155
-	 */
156
-	public function getRequestType(): string {
157
-		return $this->requestType;
158
-	}
159
-
160
-	/**
161
-	 * @return bool
162
-	 */
163
-	public function isValid(): bool {
164
-		return $this->label !== '' && $this->link !== '';
165
-	}
166
-
167
-	/**
168
-	 * @return bool
169
-	 */
170
-	public function isValidParsed(): bool {
171
-		return $this->labelParsed !== '' && $this->link !== '';
172
-	}
31
+    /** @var string */
32
+    protected $label;
33
+
34
+    /** @var string */
35
+    protected $labelParsed;
36
+
37
+    /** @var string */
38
+    protected $link;
39
+
40
+    /** @var string */
41
+    protected $requestType;
42
+
43
+    /** @var string */
44
+    protected $icon;
45
+
46
+    /** @var bool */
47
+    protected $primary;
48
+
49
+    public function __construct() {
50
+        $this->label = '';
51
+        $this->labelParsed = '';
52
+        $this->link = '';
53
+        $this->requestType = '';
54
+        $this->primary = false;
55
+    }
56
+
57
+    /**
58
+     * @param string $label
59
+     * @return $this
60
+     * @throws \InvalidArgumentException if the label is invalid
61
+     * @since 8.2.0
62
+     */
63
+    public function setLabel(string $label): IAction {
64
+        if ($label === '' || isset($label[32])) {
65
+            throw new \InvalidArgumentException('The given label is invalid');
66
+        }
67
+        $this->label = $label;
68
+        return $this;
69
+    }
70
+
71
+    /**
72
+     * @return string
73
+     * @since 8.2.0
74
+     */
75
+    public function getLabel(): string {
76
+        return $this->label;
77
+    }
78
+
79
+    /**
80
+     * @param string $label
81
+     * @return $this
82
+     * @throws \InvalidArgumentException if the label is invalid
83
+     * @since 8.2.0
84
+     */
85
+    public function setParsedLabel(string $label): IAction {
86
+        if ($label === '') {
87
+            throw new \InvalidArgumentException('The given parsed label is invalid');
88
+        }
89
+        $this->labelParsed = $label;
90
+        return $this;
91
+    }
92
+
93
+    /**
94
+     * @return string
95
+     * @since 8.2.0
96
+     */
97
+    public function getParsedLabel(): string {
98
+        return $this->labelParsed;
99
+    }
100
+
101
+    /**
102
+     * @param $primary bool
103
+     * @return $this
104
+     * @since 9.0.0
105
+     */
106
+    public function setPrimary(bool $primary): IAction {
107
+        $this->primary = $primary;
108
+        return $this;
109
+    }
110
+
111
+    /**
112
+     * @return bool
113
+     * @since 9.0.0
114
+     */
115
+    public function isPrimary(): bool {
116
+        return $this->primary;
117
+    }
118
+
119
+    /**
120
+     * @param string $link
121
+     * @param string $requestType
122
+     * @return $this
123
+     * @throws \InvalidArgumentException if the link is invalid
124
+     * @since 8.2.0
125
+     */
126
+    public function setLink(string $link, string $requestType): IAction {
127
+        if ($link === '' || isset($link[256])) {
128
+            throw new \InvalidArgumentException('The given link is invalid');
129
+        }
130
+        if (!in_array($requestType, [
131
+            self::TYPE_GET,
132
+            self::TYPE_POST,
133
+            self::TYPE_PUT,
134
+            self::TYPE_DELETE,
135
+            self::TYPE_WEB,
136
+        ], true)) {
137
+            throw new \InvalidArgumentException('The given request type is invalid');
138
+        }
139
+        $this->link = $link;
140
+        $this->requestType = $requestType;
141
+        return $this;
142
+    }
143
+
144
+    /**
145
+     * @return string
146
+     * @since 8.2.0
147
+     */
148
+    public function getLink(): string {
149
+        return $this->link;
150
+    }
151
+
152
+    /**
153
+     * @return string
154
+     * @since 8.2.0
155
+     */
156
+    public function getRequestType(): string {
157
+        return $this->requestType;
158
+    }
159
+
160
+    /**
161
+     * @return bool
162
+     */
163
+    public function isValid(): bool {
164
+        return $this->label !== '' && $this->link !== '';
165
+    }
166
+
167
+    /**
168
+     * @return bool
169
+     */
170
+    public function isValidParsed(): bool {
171
+        return $this->labelParsed !== '' && $this->link !== '';
172
+    }
173 173
 }
Please login to merge, or discard this patch.
lib/public/Notification/IApp.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -30,23 +30,23 @@
 block discarded – undo
30 30
  * @since 9.0.0
31 31
  */
32 32
 interface IApp {
33
-	/**
34
-	 * @param INotification $notification
35
-	 * @throws \InvalidArgumentException When the notification is not valid
36
-	 * @since 9.0.0
37
-	 */
38
-	public function notify(INotification $notification): void;
33
+    /**
34
+     * @param INotification $notification
35
+     * @throws \InvalidArgumentException When the notification is not valid
36
+     * @since 9.0.0
37
+     */
38
+    public function notify(INotification $notification): void;
39 39
 
40
-	/**
41
-	 * @param INotification $notification
42
-	 * @since 9.0.0
43
-	 */
44
-	public function markProcessed(INotification $notification): void;
40
+    /**
41
+     * @param INotification $notification
42
+     * @since 9.0.0
43
+     */
44
+    public function markProcessed(INotification $notification): void;
45 45
 
46
-	/**
47
-	 * @param INotification $notification
48
-	 * @return int
49
-	 * @since 9.0.0
50
-	 */
51
-	public function getCount(INotification $notification): int;
46
+    /**
47
+     * @param INotification $notification
48
+     * @return int
49
+     * @since 9.0.0
50
+     */
51
+    public function getCount(INotification $notification): int;
52 52
 }
Please login to merge, or discard this patch.
lib/public/Notification/AlreadyProcessedException.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@
 block discarded – undo
28 28
  */
29 29
 class AlreadyProcessedException extends \RuntimeException {
30 30
 
31
-	/**
32
-	 * @since 17.0.0
33
-	 */
34
-	public function __construct() {
35
-		parent::__construct('Notification is processed already');
36
-	}
31
+    /**
32
+     * @since 17.0.0
33
+     */
34
+    public function __construct() {
35
+        parent::__construct('Notification is processed already');
36
+    }
37 37
 
38 38
 }
Please login to merge, or discard this patch.
lib/public/Notification/INotifier.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -31,29 +31,29 @@
 block discarded – undo
31 31
  */
32 32
 interface INotifier {
33 33
 
34
-	/**
35
-	 * Identifier of the notifier, only use [a-z0-9_]
36
-	 *
37
-	 * @return string
38
-	 * @since 17.0.0
39
-	 */
40
-	public function getID(): string;
34
+    /**
35
+     * Identifier of the notifier, only use [a-z0-9_]
36
+     *
37
+     * @return string
38
+     * @since 17.0.0
39
+     */
40
+    public function getID(): string;
41 41
 
42
-	/**
43
-	 * Human readable name describing the notifier
44
-	 *
45
-	 * @return string
46
-	 * @since 17.0.0
47
-	 */
48
-	public function getName(): string;
42
+    /**
43
+     * Human readable name describing the notifier
44
+     *
45
+     * @return string
46
+     * @since 17.0.0
47
+     */
48
+    public function getName(): string;
49 49
 
50
-	/**
51
-	 * @param INotification $notification
52
-	 * @param string $languageCode The code of the language that should be used to prepare the notification
53
-	 * @return INotification
54
-	 * @throws \InvalidArgumentException When the notification was not prepared by a notifier
55
-	 * @throws AlreadyProcessedException When the notification is not needed anymore and should be deleted
56
-	 * @since 9.0.0
57
-	 */
58
-	public function prepare(INotification $notification, string $languageCode): INotification;
50
+    /**
51
+     * @param INotification $notification
52
+     * @param string $languageCode The code of the language that should be used to prepare the notification
53
+     * @return INotification
54
+     * @throws \InvalidArgumentException When the notification was not prepared by a notifier
55
+     * @throws AlreadyProcessedException When the notification is not needed anymore and should be deleted
56
+     * @since 9.0.0
57
+     */
58
+    public function prepare(INotification $notification, string $languageCode): INotification;
59 59
 }
Please login to merge, or discard this patch.
lib/public/Notification/INotification.php 1 patch
Indentation   +290 added lines, -290 removed lines patch added patch discarded remove patch
@@ -31,294 +31,294 @@
 block discarded – undo
31 31
  * @since 9.0.0
32 32
  */
33 33
 interface INotification {
34
-	/**
35
-	 * @param string $app
36
-	 * @return $this
37
-	 * @throws \InvalidArgumentException if the app id is invalid
38
-	 * @since 9.0.0
39
-	 */
40
-	public function setApp(string $app): INotification;
41
-
42
-	/**
43
-	 * @return string
44
-	 * @since 9.0.0
45
-	 */
46
-	public function getApp(): string;
47
-
48
-	/**
49
-	 * @param string $user
50
-	 * @return $this
51
-	 * @throws \InvalidArgumentException if the user id is invalid
52
-	 * @since 9.0.0
53
-	 */
54
-	public function setUser(string $user): INotification;
55
-
56
-	/**
57
-	 * @return string
58
-	 * @since 9.0.0
59
-	 */
60
-	public function getUser(): string;
61
-
62
-	/**
63
-	 * @param \DateTime $dateTime
64
-	 * @return $this
65
-	 * @throws \InvalidArgumentException if the $dateTime is invalid
66
-	 * @since 9.0.0
67
-	 */
68
-	public function setDateTime(\DateTime $dateTime): INotification;
69
-
70
-	/**
71
-	 * @return \DateTime
72
-	 * @since 9.0.0
73
-	 */
74
-	public function getDateTime(): \DateTime;
75
-
76
-	/**
77
-	 * @param string $type
78
-	 * @param string $id
79
-	 * @return $this
80
-	 * @throws \InvalidArgumentException if the object type or id is invalid
81
-	 * @since 9.0.0
82
-	 */
83
-	public function setObject(string $type, string $id): INotification;
84
-
85
-	/**
86
-	 * @return string
87
-	 * @since 9.0.0
88
-	 */
89
-	public function getObjectType(): string;
90
-
91
-	/**
92
-	 * @return string
93
-	 * @since 9.0.0
94
-	 */
95
-	public function getObjectId(): string;
96
-
97
-	/**
98
-	 * @param string $subject
99
-	 * @param array $parameters
100
-	 * @return $this
101
-	 * @throws \InvalidArgumentException if the subject or parameters are invalid
102
-	 * @since 9.0.0
103
-	 */
104
-	public function setSubject(string $subject, array $parameters = []): INotification;
105
-
106
-	/**
107
-	 * @return string
108
-	 * @since 9.0.0
109
-	 */
110
-	public function getSubject(): string;
111
-
112
-	/**
113
-	 * @return array
114
-	 * @since 9.0.0
115
-	 */
116
-	public function getSubjectParameters(): array;
117
-
118
-	/**
119
-	 * Set a parsed subject
120
-	 *
121
-	 * HTML is not allowed in the parsed subject and will be escaped
122
-	 * automatically by the clients. You can use the RichObjectString system
123
-	 * provided by the Nextcloud server to highlight important parameters via
124
-	 * the setRichSubject method, but make sure, that a plain text message is
125
-	 * always set via setParsedSubject, to support clients which can not handle
126
-	 * rich strings.
127
-	 *
128
-	 * See https://github.com/nextcloud/server/issues/1706 for more information.
129
-	 *
130
-	 * @param string $subject
131
-	 * @return $this
132
-	 * @throws \InvalidArgumentException if the subject is invalid
133
-	 * @since 9.0.0
134
-	 */
135
-	public function setParsedSubject(string $subject): INotification;
136
-
137
-	/**
138
-	 * @return string
139
-	 * @since 9.0.0
140
-	 */
141
-	public function getParsedSubject(): string;
142
-
143
-	/**
144
-	 * Set a RichObjectString subject
145
-	 *
146
-	 * HTML is not allowed in the rich subject and will be escaped automatically
147
-	 * by the clients, but you can use the RichObjectString system provided by
148
-	 * the Nextcloud server to highlight important parameters.
149
-	 * Also make sure, that a plain text subject is always set via
150
-	 * setParsedSubject, to support clients which can not handle rich strings.
151
-	 *
152
-	 * See https://github.com/nextcloud/server/issues/1706 for more information.
153
-	 *
154
-	 * @param string $subject
155
-	 * @param array $parameters
156
-	 * @return $this
157
-	 * @throws \InvalidArgumentException if the subject or parameters are invalid
158
-	 * @since 11.0.0
159
-	 */
160
-	public function setRichSubject(string $subject, array $parameters = []): INotification;
161
-
162
-	/**
163
-	 * @return string
164
-	 * @since 11.0.0
165
-	 */
166
-	public function getRichSubject(): string;
167
-
168
-	/**
169
-	 * @return array[]
170
-	 * @since 11.0.0
171
-	 */
172
-	public function getRichSubjectParameters(): array;
173
-
174
-	/**
175
-	 * @param string $message
176
-	 * @param array $parameters
177
-	 * @return $this
178
-	 * @throws \InvalidArgumentException if the message or parameters are invalid
179
-	 * @since 9.0.0
180
-	 */
181
-	public function setMessage(string $message, array $parameters = []): INotification;
182
-
183
-	/**
184
-	 * @return string
185
-	 * @since 9.0.0
186
-	 */
187
-	public function getMessage(): string;
188
-
189
-	/**
190
-	 * @return array
191
-	 * @since 9.0.0
192
-	 */
193
-	public function getMessageParameters(): array;
194
-
195
-	/**
196
-	 * Set a parsed message
197
-	 *
198
-	 * HTML is not allowed in the parsed message and will be escaped
199
-	 * automatically by the clients. You can use the RichObjectString system
200
-	 * provided by the Nextcloud server to highlight important parameters via
201
-	 * the setRichMessage method, but make sure, that a plain text message is
202
-	 * always set via setParsedMessage, to support clients which can not handle
203
-	 * rich strings.
204
-	 *
205
-	 * See https://github.com/nextcloud/server/issues/1706 for more information.
206
-	 *
207
-	 * @param string $message
208
-	 * @return $this
209
-	 * @throws \InvalidArgumentException if the message is invalid
210
-	 * @since 9.0.0
211
-	 */
212
-	public function setParsedMessage(string $message): INotification;
213
-
214
-	/**
215
-	 * @return string
216
-	 * @since 9.0.0
217
-	 */
218
-	public function getParsedMessage(): string;
219
-
220
-	/**
221
-	 * Set a RichObjectString message
222
-	 *
223
-	 * HTML is not allowed in the rich message and will be escaped automatically
224
-	 * by the clients, but you can use the RichObjectString system provided by
225
-	 * the Nextcloud server to highlight important parameters.
226
-	 * Also make sure, that a plain text message is always set via
227
-	 * setParsedMessage, to support clients which can not handle rich strings.
228
-	 *
229
-	 * See https://github.com/nextcloud/server/issues/1706 for more information.
230
-	 *
231
-	 * @param string $message
232
-	 * @param array $parameters
233
-	 * @return $this
234
-	 * @throws \InvalidArgumentException if the message or parameters are invalid
235
-	 * @since 11.0.0
236
-	 */
237
-	public function setRichMessage(string $message, array $parameters = []): INotification;
238
-
239
-	/**
240
-	 * @return string
241
-	 * @since 11.0.0
242
-	 */
243
-	public function getRichMessage(): string;
244
-
245
-	/**
246
-	 * @return array[]
247
-	 * @since 11.0.0
248
-	 */
249
-	public function getRichMessageParameters(): array;
250
-
251
-	/**
252
-	 * @param string $link
253
-	 * @return $this
254
-	 * @throws \InvalidArgumentException if the link is invalid
255
-	 * @since 9.0.0
256
-	 */
257
-	public function setLink(string $link): INotification;
258
-
259
-	/**
260
-	 * @return string
261
-	 * @since 9.0.0
262
-	 */
263
-	public function getLink(): string;
264
-
265
-	/**
266
-	 * @param string $icon
267
-	 * @return $this
268
-	 * @throws \InvalidArgumentException if the icon is invalid
269
-	 * @since 11.0.0
270
-	 */
271
-	public function setIcon(string $icon): INotification;
272
-
273
-	/**
274
-	 * @return string
275
-	 * @since 11.0.0
276
-	 */
277
-	public function getIcon(): string;
278
-
279
-	/**
280
-	 * @return IAction
281
-	 * @since 9.0.0
282
-	 */
283
-	public function createAction(): IAction;
284
-
285
-	/**
286
-	 * @param IAction $action
287
-	 * @return $this
288
-	 * @throws \InvalidArgumentException if the action is invalid
289
-	 * @since 9.0.0
290
-	 */
291
-	public function addAction(IAction $action): INotification;
292
-
293
-	/**
294
-	 * @return IAction[]
295
-	 * @since 9.0.0
296
-	 */
297
-	public function getActions(): array;
298
-
299
-	/**
300
-	 * @param IAction $action
301
-	 * @return $this
302
-	 * @throws \InvalidArgumentException if the action is invalid
303
-	 * @since 9.0.0
304
-	 */
305
-	public function addParsedAction(IAction $action): INotification;
306
-
307
-	/**
308
-	 * @return IAction[]
309
-	 * @since 9.0.0
310
-	 */
311
-	public function getParsedActions(): array;
312
-
313
-	/**
314
-	 * @return bool
315
-	 * @since 9.0.0
316
-	 */
317
-	public function isValid(): bool;
318
-
319
-	/**
320
-	 * @return bool
321
-	 * @since 9.0.0
322
-	 */
323
-	public function isValidParsed(): bool;
34
+    /**
35
+     * @param string $app
36
+     * @return $this
37
+     * @throws \InvalidArgumentException if the app id is invalid
38
+     * @since 9.0.0
39
+     */
40
+    public function setApp(string $app): INotification;
41
+
42
+    /**
43
+     * @return string
44
+     * @since 9.0.0
45
+     */
46
+    public function getApp(): string;
47
+
48
+    /**
49
+     * @param string $user
50
+     * @return $this
51
+     * @throws \InvalidArgumentException if the user id is invalid
52
+     * @since 9.0.0
53
+     */
54
+    public function setUser(string $user): INotification;
55
+
56
+    /**
57
+     * @return string
58
+     * @since 9.0.0
59
+     */
60
+    public function getUser(): string;
61
+
62
+    /**
63
+     * @param \DateTime $dateTime
64
+     * @return $this
65
+     * @throws \InvalidArgumentException if the $dateTime is invalid
66
+     * @since 9.0.0
67
+     */
68
+    public function setDateTime(\DateTime $dateTime): INotification;
69
+
70
+    /**
71
+     * @return \DateTime
72
+     * @since 9.0.0
73
+     */
74
+    public function getDateTime(): \DateTime;
75
+
76
+    /**
77
+     * @param string $type
78
+     * @param string $id
79
+     * @return $this
80
+     * @throws \InvalidArgumentException if the object type or id is invalid
81
+     * @since 9.0.0
82
+     */
83
+    public function setObject(string $type, string $id): INotification;
84
+
85
+    /**
86
+     * @return string
87
+     * @since 9.0.0
88
+     */
89
+    public function getObjectType(): string;
90
+
91
+    /**
92
+     * @return string
93
+     * @since 9.0.0
94
+     */
95
+    public function getObjectId(): string;
96
+
97
+    /**
98
+     * @param string $subject
99
+     * @param array $parameters
100
+     * @return $this
101
+     * @throws \InvalidArgumentException if the subject or parameters are invalid
102
+     * @since 9.0.0
103
+     */
104
+    public function setSubject(string $subject, array $parameters = []): INotification;
105
+
106
+    /**
107
+     * @return string
108
+     * @since 9.0.0
109
+     */
110
+    public function getSubject(): string;
111
+
112
+    /**
113
+     * @return array
114
+     * @since 9.0.0
115
+     */
116
+    public function getSubjectParameters(): array;
117
+
118
+    /**
119
+     * Set a parsed subject
120
+     *
121
+     * HTML is not allowed in the parsed subject and will be escaped
122
+     * automatically by the clients. You can use the RichObjectString system
123
+     * provided by the Nextcloud server to highlight important parameters via
124
+     * the setRichSubject method, but make sure, that a plain text message is
125
+     * always set via setParsedSubject, to support clients which can not handle
126
+     * rich strings.
127
+     *
128
+     * See https://github.com/nextcloud/server/issues/1706 for more information.
129
+     *
130
+     * @param string $subject
131
+     * @return $this
132
+     * @throws \InvalidArgumentException if the subject is invalid
133
+     * @since 9.0.0
134
+     */
135
+    public function setParsedSubject(string $subject): INotification;
136
+
137
+    /**
138
+     * @return string
139
+     * @since 9.0.0
140
+     */
141
+    public function getParsedSubject(): string;
142
+
143
+    /**
144
+     * Set a RichObjectString subject
145
+     *
146
+     * HTML is not allowed in the rich subject and will be escaped automatically
147
+     * by the clients, but you can use the RichObjectString system provided by
148
+     * the Nextcloud server to highlight important parameters.
149
+     * Also make sure, that a plain text subject is always set via
150
+     * setParsedSubject, to support clients which can not handle rich strings.
151
+     *
152
+     * See https://github.com/nextcloud/server/issues/1706 for more information.
153
+     *
154
+     * @param string $subject
155
+     * @param array $parameters
156
+     * @return $this
157
+     * @throws \InvalidArgumentException if the subject or parameters are invalid
158
+     * @since 11.0.0
159
+     */
160
+    public function setRichSubject(string $subject, array $parameters = []): INotification;
161
+
162
+    /**
163
+     * @return string
164
+     * @since 11.0.0
165
+     */
166
+    public function getRichSubject(): string;
167
+
168
+    /**
169
+     * @return array[]
170
+     * @since 11.0.0
171
+     */
172
+    public function getRichSubjectParameters(): array;
173
+
174
+    /**
175
+     * @param string $message
176
+     * @param array $parameters
177
+     * @return $this
178
+     * @throws \InvalidArgumentException if the message or parameters are invalid
179
+     * @since 9.0.0
180
+     */
181
+    public function setMessage(string $message, array $parameters = []): INotification;
182
+
183
+    /**
184
+     * @return string
185
+     * @since 9.0.0
186
+     */
187
+    public function getMessage(): string;
188
+
189
+    /**
190
+     * @return array
191
+     * @since 9.0.0
192
+     */
193
+    public function getMessageParameters(): array;
194
+
195
+    /**
196
+     * Set a parsed message
197
+     *
198
+     * HTML is not allowed in the parsed message and will be escaped
199
+     * automatically by the clients. You can use the RichObjectString system
200
+     * provided by the Nextcloud server to highlight important parameters via
201
+     * the setRichMessage method, but make sure, that a plain text message is
202
+     * always set via setParsedMessage, to support clients which can not handle
203
+     * rich strings.
204
+     *
205
+     * See https://github.com/nextcloud/server/issues/1706 for more information.
206
+     *
207
+     * @param string $message
208
+     * @return $this
209
+     * @throws \InvalidArgumentException if the message is invalid
210
+     * @since 9.0.0
211
+     */
212
+    public function setParsedMessage(string $message): INotification;
213
+
214
+    /**
215
+     * @return string
216
+     * @since 9.0.0
217
+     */
218
+    public function getParsedMessage(): string;
219
+
220
+    /**
221
+     * Set a RichObjectString message
222
+     *
223
+     * HTML is not allowed in the rich message and will be escaped automatically
224
+     * by the clients, but you can use the RichObjectString system provided by
225
+     * the Nextcloud server to highlight important parameters.
226
+     * Also make sure, that a plain text message is always set via
227
+     * setParsedMessage, to support clients which can not handle rich strings.
228
+     *
229
+     * See https://github.com/nextcloud/server/issues/1706 for more information.
230
+     *
231
+     * @param string $message
232
+     * @param array $parameters
233
+     * @return $this
234
+     * @throws \InvalidArgumentException if the message or parameters are invalid
235
+     * @since 11.0.0
236
+     */
237
+    public function setRichMessage(string $message, array $parameters = []): INotification;
238
+
239
+    /**
240
+     * @return string
241
+     * @since 11.0.0
242
+     */
243
+    public function getRichMessage(): string;
244
+
245
+    /**
246
+     * @return array[]
247
+     * @since 11.0.0
248
+     */
249
+    public function getRichMessageParameters(): array;
250
+
251
+    /**
252
+     * @param string $link
253
+     * @return $this
254
+     * @throws \InvalidArgumentException if the link is invalid
255
+     * @since 9.0.0
256
+     */
257
+    public function setLink(string $link): INotification;
258
+
259
+    /**
260
+     * @return string
261
+     * @since 9.0.0
262
+     */
263
+    public function getLink(): string;
264
+
265
+    /**
266
+     * @param string $icon
267
+     * @return $this
268
+     * @throws \InvalidArgumentException if the icon is invalid
269
+     * @since 11.0.0
270
+     */
271
+    public function setIcon(string $icon): INotification;
272
+
273
+    /**
274
+     * @return string
275
+     * @since 11.0.0
276
+     */
277
+    public function getIcon(): string;
278
+
279
+    /**
280
+     * @return IAction
281
+     * @since 9.0.0
282
+     */
283
+    public function createAction(): IAction;
284
+
285
+    /**
286
+     * @param IAction $action
287
+     * @return $this
288
+     * @throws \InvalidArgumentException if the action is invalid
289
+     * @since 9.0.0
290
+     */
291
+    public function addAction(IAction $action): INotification;
292
+
293
+    /**
294
+     * @return IAction[]
295
+     * @since 9.0.0
296
+     */
297
+    public function getActions(): array;
298
+
299
+    /**
300
+     * @param IAction $action
301
+     * @return $this
302
+     * @throws \InvalidArgumentException if the action is invalid
303
+     * @since 9.0.0
304
+     */
305
+    public function addParsedAction(IAction $action): INotification;
306
+
307
+    /**
308
+     * @return IAction[]
309
+     * @since 9.0.0
310
+     */
311
+    public function getParsedActions(): array;
312
+
313
+    /**
314
+     * @return bool
315
+     * @since 9.0.0
316
+     */
317
+    public function isValid(): bool;
318
+
319
+    /**
320
+     * @return bool
321
+     * @since 9.0.0
322
+     */
323
+    public function isValidParsed(): bool;
324 324
 }
Please login to merge, or discard this patch.
apps/lookup_server_connector/lib/UpdateLookupServer.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -34,51 +34,51 @@
 block discarded – undo
34 34
  * @package OCA\LookupServerConnector
35 35
  */
36 36
 class UpdateLookupServer {
37
-	/** @var IConfig */
38
-	private $config;
39
-	/** @var IJobList */
40
-	private $jobList;
37
+    /** @var IConfig */
38
+    private $config;
39
+    /** @var IJobList */
40
+    private $jobList;
41 41
 
42
-	/**
43
-	 * @param IJobList $jobList
44
-	 * @param IConfig $config
45
-	 */
46
-	public function __construct(IJobList $jobList,
47
-								IConfig $config) {
48
-		$this->config = $config;
49
-		$this->jobList = $jobList;
50
-	}
42
+    /**
43
+     * @param IJobList $jobList
44
+     * @param IConfig $config
45
+     */
46
+    public function __construct(IJobList $jobList,
47
+                                IConfig $config) {
48
+        $this->config = $config;
49
+        $this->jobList = $jobList;
50
+    }
51 51
 
52
-	/**
53
-	 * @param IUser $user
54
-	 */
55
-	public function userUpdated(IUser $user): void {
56
-		if (!$this->shouldUpdateLookupServer()) {
57
-			return;
58
-		}
52
+    /**
53
+     * @param IUser $user
54
+     */
55
+    public function userUpdated(IUser $user): void {
56
+        if (!$this->shouldUpdateLookupServer()) {
57
+            return;
58
+        }
59 59
 
60
-		// Reset retry counter
61
-		$this->config->deleteUserValue(
62
-			$user->getUID(),
63
-			'lookup_server_connector',
64
-			'update_retries'
65
-		);
66
-		$this->jobList->add(RetryJob::class, ['userId' => $user->getUID()]);
67
-	}
60
+        // Reset retry counter
61
+        $this->config->deleteUserValue(
62
+            $user->getUID(),
63
+            'lookup_server_connector',
64
+            'update_retries'
65
+        );
66
+        $this->jobList->add(RetryJob::class, ['userId' => $user->getUID()]);
67
+    }
68 68
 
69
-	/**
70
-	 * check if we should update the lookup server, we only do it if
71
-	 *
72
-	 * + we have an internet connection
73
-	 * + the lookup server update was not disabled by the admin
74
-	 * + we have a valid lookup server URL
75
-	 *
76
-	 * @return bool
77
-	 */
78
-	private function shouldUpdateLookupServer(): bool {
79
-		return $this->config->getSystemValueBool('has_internet_connection', true) === true &&
80
-			$this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'yes') === 'yes' &&
81
-			$this->config->getSystemValueString('lookup_server', 'https://lookup.nextcloud.com') !== '';
82
-	}
69
+    /**
70
+     * check if we should update the lookup server, we only do it if
71
+     *
72
+     * + we have an internet connection
73
+     * + the lookup server update was not disabled by the admin
74
+     * + we have a valid lookup server URL
75
+     *
76
+     * @return bool
77
+     */
78
+    private function shouldUpdateLookupServer(): bool {
79
+        return $this->config->getSystemValueBool('has_internet_connection', true) === true &&
80
+            $this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'yes') === 'yes' &&
81
+            $this->config->getSystemValueString('lookup_server', 'https://lookup.nextcloud.com') !== '';
82
+    }
83 83
 
84 84
 }
Please login to merge, or discard this patch.