Completed
Pull Request — master (#7418)
by Blizzz
28:19 queued 13:51
created
lib/private/Session/Session.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -28,53 +28,53 @@
 block discarded – undo
28 28
 
29 29
 abstract class Session implements \ArrayAccess, ISession {
30 30
 
31
-	/**
32
-	 * @var bool
33
-	 */
34
-	protected $sessionClosed = false;
31
+    /**
32
+     * @var bool
33
+     */
34
+    protected $sessionClosed = false;
35 35
 
36
-	/**
37
-	 * $name serves as a namespace for the session keys
38
-	 *
39
-	 * @param string $name
40
-	 */
41
-	abstract public function __construct($name);
36
+    /**
37
+     * $name serves as a namespace for the session keys
38
+     *
39
+     * @param string $name
40
+     */
41
+    abstract public function __construct($name);
42 42
 
43
-	/**
44
-	 * @param mixed $offset
45
-	 * @return bool
46
-	 */
47
-	public function offsetExists($offset) {
48
-		return $this->exists($offset);
49
-	}
43
+    /**
44
+     * @param mixed $offset
45
+     * @return bool
46
+     */
47
+    public function offsetExists($offset) {
48
+        return $this->exists($offset);
49
+    }
50 50
 
51
-	/**
52
-	 * @param mixed $offset
53
-	 * @return mixed
54
-	 */
55
-	public function offsetGet($offset) {
56
-		return $this->get($offset);
57
-	}
51
+    /**
52
+     * @param mixed $offset
53
+     * @return mixed
54
+     */
55
+    public function offsetGet($offset) {
56
+        return $this->get($offset);
57
+    }
58 58
 
59
-	/**
60
-	 * @param mixed $offset
61
-	 * @param mixed $value
62
-	 */
63
-	public function offsetSet($offset, $value) {
64
-		$this->set($offset, $value);
65
-	}
59
+    /**
60
+     * @param mixed $offset
61
+     * @param mixed $value
62
+     */
63
+    public function offsetSet($offset, $value) {
64
+        $this->set($offset, $value);
65
+    }
66 66
 
67
-	/**
68
-	 * @param mixed $offset
69
-	 */
70
-	public function offsetUnset($offset) {
71
-		$this->remove($offset);
72
-	}
67
+    /**
68
+     * @param mixed $offset
69
+     */
70
+    public function offsetUnset($offset) {
71
+        $this->remove($offset);
72
+    }
73 73
 
74
-	/**
75
-	 * Close the session and release the lock
76
-	 */
77
-	public function close() {
78
-		$this->sessionClosed = true;
79
-	}
74
+    /**
75
+     * Close the session and release the lock
76
+     */
77
+    public function close() {
78
+        $this->sessionClosed = true;
79
+    }
80 80
 }
Please login to merge, or discard this patch.
lib/private/Session/CryptoWrapper.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@
 block discarded – undo
81 81
 			// FIXME: Required for CI
82 82
 			if (!defined('PHPUNIT_RUN')) {
83 83
 				$webRoot = \OC::$WEBROOT;
84
-				if($webRoot === '') {
84
+				if ($webRoot === '') {
85 85
 					$webRoot = '/';
86 86
 				}
87 87
 				setcookie(self::COOKIE_NAME, $this->passphrase, 0, $webRoot, '', $secureCookie, true);
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -48,58 +48,58 @@
 block discarded – undo
48 48
  * @package OC\Session
49 49
  */
50 50
 class CryptoWrapper {
51
-	const COOKIE_NAME = 'oc_sessionPassphrase';
51
+    const COOKIE_NAME = 'oc_sessionPassphrase';
52 52
 
53
-	/** @var IConfig */
54
-	protected $config;
55
-	/** @var ISession */
56
-	protected $session;
57
-	/** @var ICrypto */
58
-	protected $crypto;
59
-	/** @var ISecureRandom */
60
-	protected $random;
61
-	/** @var string */
62
-	protected $passphrase;
53
+    /** @var IConfig */
54
+    protected $config;
55
+    /** @var ISession */
56
+    protected $session;
57
+    /** @var ICrypto */
58
+    protected $crypto;
59
+    /** @var ISecureRandom */
60
+    protected $random;
61
+    /** @var string */
62
+    protected $passphrase;
63 63
 
64
-	/**
65
-	 * @param IConfig $config
66
-	 * @param ICrypto $crypto
67
-	 * @param ISecureRandom $random
68
-	 * @param IRequest $request
69
-	 */
70
-	public function __construct(IConfig $config,
71
-								ICrypto $crypto,
72
-								ISecureRandom $random,
73
-								IRequest $request) {
74
-		$this->crypto = $crypto;
75
-		$this->config = $config;
76
-		$this->random = $random;
64
+    /**
65
+     * @param IConfig $config
66
+     * @param ICrypto $crypto
67
+     * @param ISecureRandom $random
68
+     * @param IRequest $request
69
+     */
70
+    public function __construct(IConfig $config,
71
+                                ICrypto $crypto,
72
+                                ISecureRandom $random,
73
+                                IRequest $request) {
74
+        $this->crypto = $crypto;
75
+        $this->config = $config;
76
+        $this->random = $random;
77 77
 
78
-		if (!is_null($request->getCookie(self::COOKIE_NAME))) {
79
-			$this->passphrase = $request->getCookie(self::COOKIE_NAME);
80
-		} else {
81
-			$this->passphrase = $this->random->generate(128);
82
-			$secureCookie = $request->getServerProtocol() === 'https';
83
-			// FIXME: Required for CI
84
-			if (!defined('PHPUNIT_RUN')) {
85
-				$webRoot = \OC::$WEBROOT;
86
-				if($webRoot === '') {
87
-					$webRoot = '/';
88
-				}
89
-				setcookie(self::COOKIE_NAME, $this->passphrase, 0, $webRoot, '', $secureCookie, true);
90
-			}
91
-		}
92
-	}
78
+        if (!is_null($request->getCookie(self::COOKIE_NAME))) {
79
+            $this->passphrase = $request->getCookie(self::COOKIE_NAME);
80
+        } else {
81
+            $this->passphrase = $this->random->generate(128);
82
+            $secureCookie = $request->getServerProtocol() === 'https';
83
+            // FIXME: Required for CI
84
+            if (!defined('PHPUNIT_RUN')) {
85
+                $webRoot = \OC::$WEBROOT;
86
+                if($webRoot === '') {
87
+                    $webRoot = '/';
88
+                }
89
+                setcookie(self::COOKIE_NAME, $this->passphrase, 0, $webRoot, '', $secureCookie, true);
90
+            }
91
+        }
92
+    }
93 93
 
94
-	/**
95
-	 * @param ISession $session
96
-	 * @return ISession
97
-	 */
98
-	public function wrapSession(ISession $session) {
99
-		if (!($session instanceof CryptoSessionData)) {
100
-			return new CryptoSessionData($session, $this->crypto, $this->passphrase);
101
-		}
94
+    /**
95
+     * @param ISession $session
96
+     * @return ISession
97
+     */
98
+    public function wrapSession(ISession $session) {
99
+        if (!($session instanceof CryptoSessionData)) {
100
+            return new CryptoSessionData($session, $this->crypto, $this->passphrase);
101
+        }
102 102
 
103
-		return $session;
104
-	}
103
+        return $session;
104
+    }
105 105
 }
Please login to merge, or discard this patch.
lib/private/Comments/Comment.php 2 patches
Indentation   +389 added lines, -389 removed lines patch added patch discarded remove patch
@@ -29,393 +29,393 @@
 block discarded – undo
29 29
 
30 30
 class Comment implements IComment {
31 31
 
32
-	protected $data = [
33
-		'id'              => '',
34
-		'parentId'        => '0',
35
-		'topmostParentId' => '0',
36
-		'childrenCount'   => '0',
37
-		'message'         => '',
38
-		'verb'            => '',
39
-		'actorType'       => '',
40
-		'actorId'         => '',
41
-		'objectType'      => '',
42
-		'objectId'        => '',
43
-		'creationDT'      => null,
44
-		'latestChildDT'   => null,
45
-	];
46
-
47
-	/**
48
-	 * Comment constructor.
49
-	 *
50
-	 * @param array $data	optional, array with keys according to column names from
51
-	 * 						the comments database scheme
52
-	 */
53
-	public function __construct(array $data = null) {
54
-		if(is_array($data)) {
55
-			$this->fromArray($data);
56
-		}
57
-	}
58
-
59
-	/**
60
-	 * returns the ID of the comment
61
-	 *
62
-	 * It may return an empty string, if the comment was not stored.
63
-	 * It is expected that the concrete Comment implementation gives an ID
64
-	 * by itself (e.g. after saving).
65
-	 *
66
-	 * @return string
67
-	 * @since 9.0.0
68
-	 */
69
-	public function getId() {
70
-		return $this->data['id'];
71
-	}
72
-
73
-	/**
74
-	 * sets the ID of the comment and returns itself
75
-	 *
76
-	 * It is only allowed to set the ID only, if the current id is an empty
77
-	 * string (which means it is not stored in a database, storage or whatever
78
-	 * the concrete implementation does), or vice versa. Changing a given ID is
79
-	 * not permitted and must result in an IllegalIDChangeException.
80
-	 *
81
-	 * @param string $id
82
-	 * @return IComment
83
-	 * @throws IllegalIDChangeException
84
-	 * @since 9.0.0
85
-	 */
86
-	public function setId($id) {
87
-		if(!is_string($id)) {
88
-			throw new \InvalidArgumentException('String expected.');
89
-		}
90
-
91
-		$id = trim($id);
92
-		if($this->data['id'] === '' || ($this->data['id'] !== '' && $id === '')) {
93
-			$this->data['id'] = $id;
94
-			return $this;
95
-		}
96
-
97
-		throw new IllegalIDChangeException('Not allowed to assign a new ID to an already saved comment.');
98
-	}
99
-
100
-	/**
101
-	 * returns the parent ID of the comment
102
-	 *
103
-	 * @return string
104
-	 * @since 9.0.0
105
-	 */
106
-	public function getParentId() {
107
-		return $this->data['parentId'];
108
-	}
109
-
110
-	/**
111
-	 * sets the parent ID and returns itself
112
-	 *
113
-	 * @param string $parentId
114
-	 * @return IComment
115
-	 * @since 9.0.0
116
-	 */
117
-	public function setParentId($parentId) {
118
-		if(!is_string($parentId)) {
119
-			throw new \InvalidArgumentException('String expected.');
120
-		}
121
-		$this->data['parentId'] = trim($parentId);
122
-		return $this;
123
-	}
124
-
125
-	/**
126
-	 * returns the topmost parent ID of the comment
127
-	 *
128
-	 * @return string
129
-	 * @since 9.0.0
130
-	 */
131
-	public function getTopmostParentId() {
132
-		return $this->data['topmostParentId'];
133
-	}
134
-
135
-
136
-	/**
137
-	 * sets the topmost parent ID and returns itself
138
-	 *
139
-	 * @param string $id
140
-	 * @return IComment
141
-	 * @since 9.0.0
142
-	 */
143
-	public function setTopmostParentId($id) {
144
-		if(!is_string($id)) {
145
-			throw new \InvalidArgumentException('String expected.');
146
-		}
147
-		$this->data['topmostParentId'] = trim($id);
148
-		return $this;
149
-	}
150
-
151
-	/**
152
-	 * returns the number of children
153
-	 *
154
-	 * @return int
155
-	 * @since 9.0.0
156
-	 */
157
-	public function getChildrenCount() {
158
-		return $this->data['childrenCount'];
159
-	}
160
-
161
-	/**
162
-	 * sets the number of children
163
-	 *
164
-	 * @param int $count
165
-	 * @return IComment
166
-	 * @since 9.0.0
167
-	 */
168
-	public function setChildrenCount($count) {
169
-		if(!is_int($count)) {
170
-			throw new \InvalidArgumentException('Integer expected.');
171
-		}
172
-		$this->data['childrenCount'] = $count;
173
-		return $this;
174
-	}
175
-
176
-	/**
177
-	 * returns the message of the comment
178
-	 *
179
-	 * @return string
180
-	 * @since 9.0.0
181
-	 */
182
-	public function getMessage() {
183
-		return $this->data['message'];
184
-	}
185
-
186
-	/**
187
-	 * sets the message of the comment and returns itself
188
-	 *
189
-	 * @param string $message
190
-	 * @return IComment
191
-	 * @throws MessageTooLongException
192
-	 * @since 9.0.0
193
-	 */
194
-	public function setMessage($message) {
195
-		if(!is_string($message)) {
196
-			throw new \InvalidArgumentException('String expected.');
197
-		}
198
-		$message = trim($message);
199
-		if(mb_strlen($message, 'UTF-8') > IComment::MAX_MESSAGE_LENGTH) {
200
-			throw new MessageTooLongException('Comment message must not exceed ' . IComment::MAX_MESSAGE_LENGTH . ' characters');
201
-		}
202
-		$this->data['message'] = $message;
203
-		return $this;
204
-	}
205
-
206
-	/**
207
-	 * returns an array containing mentions that are included in the comment
208
-	 *
209
-	 * @return array each mention provides a 'type' and an 'id', see example below
210
-	 * @since 11.0.0
211
-	 *
212
-	 * The return array looks like:
213
-	 * [
214
-	 *   [
215
-	 *     'type' => 'user',
216
-	 *     'id' => 'citizen4'
217
-	 *   ],
218
-	 *   [
219
-	 *     'type' => 'group',
220
-	 *     'id' => 'media'
221
-	 *   ],
222
-	 *   …
223
-	 * ]
224
-	 *
225
-	 */
226
-	public function getMentions() {
227
-		$ok = preg_match_all('/\B@[a-z0-9_\-@\.\']+/i', $this->getMessage(), $mentions);
228
-		if(!$ok || !isset($mentions[0]) || !is_array($mentions[0])) {
229
-			return [];
230
-		}
231
-		$uids = array_unique($mentions[0]);
232
-		$result = [];
233
-		foreach ($uids as $uid) {
234
-			// exclude author, no self-mentioning
235
-			if($uid === '@' . $this->getActorId()) {
236
-				continue;
237
-			}
238
-			$result[] = ['type' => 'user', 'id' => substr($uid, 1)];
239
-		}
240
-		return $result;
241
-	}
242
-
243
-	/**
244
-	 * returns the verb of the comment
245
-	 *
246
-	 * @return string
247
-	 * @since 9.0.0
248
-	 */
249
-	public function getVerb() {
250
-		return $this->data['verb'];
251
-	}
252
-
253
-	/**
254
-	 * sets the verb of the comment, e.g. 'comment' or 'like'
255
-	 *
256
-	 * @param string $verb
257
-	 * @return IComment
258
-	 * @since 9.0.0
259
-	 */
260
-	public function setVerb($verb) {
261
-		if(!is_string($verb) || !trim($verb)) {
262
-			throw new \InvalidArgumentException('Non-empty String expected.');
263
-		}
264
-		$this->data['verb'] = trim($verb);
265
-		return $this;
266
-	}
267
-
268
-	/**
269
-	 * returns the actor type
270
-	 *
271
-	 * @return string
272
-	 * @since 9.0.0
273
-	 */
274
-	public function getActorType() {
275
-		return $this->data['actorType'];
276
-	}
277
-
278
-	/**
279
-	 * returns the actor ID
280
-	 *
281
-	 * @return string
282
-	 * @since 9.0.0
283
-	 */
284
-	public function getActorId() {
285
-		return $this->data['actorId'];
286
-	}
287
-
288
-	/**
289
-	 * sets (overwrites) the actor type and id
290
-	 *
291
-	 * @param string $actorType e.g. 'users'
292
-	 * @param string $actorId e.g. 'zombie234'
293
-	 * @return IComment
294
-	 * @since 9.0.0
295
-	 */
296
-	public function setActor($actorType, $actorId) {
297
-		if(
298
-		       !is_string($actorType) || !trim($actorType)
299
-		    || !is_string($actorId)   || !trim($actorId)
300
-		) {
301
-			throw new \InvalidArgumentException('String expected.');
302
-		}
303
-		$this->data['actorType'] = trim($actorType);
304
-		$this->data['actorId']   = trim($actorId);
305
-		return $this;
306
-	}
307
-
308
-	/**
309
-	 * returns the creation date of the comment.
310
-	 *
311
-	 * If not explicitly set, it shall default to the time of initialization.
312
-	 *
313
-	 * @return \DateTime
314
-	 * @since 9.0.0
315
-	 */
316
-	public function getCreationDateTime() {
317
-		return $this->data['creationDT'];
318
-	}
319
-
320
-	/**
321
-	 * sets the creation date of the comment and returns itself
322
-	 *
323
-	 * @param \DateTime $timestamp
324
-	 * @return IComment
325
-	 * @since 9.0.0
326
-	 */
327
-	public function setCreationDateTime(\DateTime $timestamp) {
328
-		$this->data['creationDT'] = $timestamp;
329
-		return $this;
330
-	}
331
-
332
-	/**
333
-	 * returns the DateTime of the most recent child, if set, otherwise null
334
-	 *
335
-	 * @return \DateTime|null
336
-	 * @since 9.0.0
337
-	 */
338
-	public function getLatestChildDateTime() {
339
-		return $this->data['latestChildDT'];
340
-	}
341
-
342
-	/**
343
-	 * sets the date of the most recent child
344
-	 *
345
-	 * @param \DateTime $dateTime
346
-	 * @return IComment
347
-	 * @since 9.0.0
348
-	 */
349
-	public function setLatestChildDateTime(\DateTime $dateTime = null) {
350
-		$this->data['latestChildDT'] = $dateTime;
351
-		return $this;
352
-	}
353
-
354
-	/**
355
-	 * returns the object type the comment is attached to
356
-	 *
357
-	 * @return string
358
-	 * @since 9.0.0
359
-	 */
360
-	public function getObjectType() {
361
-		return $this->data['objectType'];
362
-	}
363
-
364
-	/**
365
-	 * returns the object id the comment is attached to
366
-	 *
367
-	 * @return string
368
-	 * @since 9.0.0
369
-	 */
370
-	public function getObjectId() {
371
-		return $this->data['objectId'];
372
-	}
373
-
374
-	/**
375
-	 * sets (overwrites) the object of the comment
376
-	 *
377
-	 * @param string $objectType e.g. 'files'
378
-	 * @param string $objectId e.g. '16435'
379
-	 * @return IComment
380
-	 * @since 9.0.0
381
-	 */
382
-	public function setObject($objectType, $objectId) {
383
-		if(
384
-		       !is_string($objectType) || !trim($objectType)
385
-		    || !is_string($objectId)   || !trim($objectId)
386
-		) {
387
-			throw new \InvalidArgumentException('String expected.');
388
-		}
389
-		$this->data['objectType'] = trim($objectType);
390
-		$this->data['objectId']   = trim($objectId);
391
-		return $this;
392
-	}
393
-
394
-	/**
395
-	 * sets the comment data based on an array with keys as taken from the
396
-	 * database.
397
-	 *
398
-	 * @param array $data
399
-	 * @return IComment
400
-	 */
401
-	protected function fromArray($data) {
402
-		foreach(array_keys($data) as $key) {
403
-			// translate DB keys to internal setter names
404
-			$setter = 'set' . implode('', array_map('ucfirst', explode('_', $key)));
405
-			$setter = str_replace('Timestamp', 'DateTime', $setter);
406
-
407
-			if(method_exists($this, $setter)) {
408
-				$this->$setter($data[$key]);
409
-			}
410
-		}
411
-
412
-		foreach(['actor', 'object'] as $role) {
413
-			if(isset($data[$role . '_type']) && isset($data[$role . '_id'])) {
414
-				$setter = 'set' . ucfirst($role);
415
-				$this->$setter($data[$role . '_type'], $data[$role . '_id']);
416
-			}
417
-		}
418
-
419
-		return $this;
420
-	}
32
+    protected $data = [
33
+        'id'              => '',
34
+        'parentId'        => '0',
35
+        'topmostParentId' => '0',
36
+        'childrenCount'   => '0',
37
+        'message'         => '',
38
+        'verb'            => '',
39
+        'actorType'       => '',
40
+        'actorId'         => '',
41
+        'objectType'      => '',
42
+        'objectId'        => '',
43
+        'creationDT'      => null,
44
+        'latestChildDT'   => null,
45
+    ];
46
+
47
+    /**
48
+     * Comment constructor.
49
+     *
50
+     * @param array $data	optional, array with keys according to column names from
51
+     * 						the comments database scheme
52
+     */
53
+    public function __construct(array $data = null) {
54
+        if(is_array($data)) {
55
+            $this->fromArray($data);
56
+        }
57
+    }
58
+
59
+    /**
60
+     * returns the ID of the comment
61
+     *
62
+     * It may return an empty string, if the comment was not stored.
63
+     * It is expected that the concrete Comment implementation gives an ID
64
+     * by itself (e.g. after saving).
65
+     *
66
+     * @return string
67
+     * @since 9.0.0
68
+     */
69
+    public function getId() {
70
+        return $this->data['id'];
71
+    }
72
+
73
+    /**
74
+     * sets the ID of the comment and returns itself
75
+     *
76
+     * It is only allowed to set the ID only, if the current id is an empty
77
+     * string (which means it is not stored in a database, storage or whatever
78
+     * the concrete implementation does), or vice versa. Changing a given ID is
79
+     * not permitted and must result in an IllegalIDChangeException.
80
+     *
81
+     * @param string $id
82
+     * @return IComment
83
+     * @throws IllegalIDChangeException
84
+     * @since 9.0.0
85
+     */
86
+    public function setId($id) {
87
+        if(!is_string($id)) {
88
+            throw new \InvalidArgumentException('String expected.');
89
+        }
90
+
91
+        $id = trim($id);
92
+        if($this->data['id'] === '' || ($this->data['id'] !== '' && $id === '')) {
93
+            $this->data['id'] = $id;
94
+            return $this;
95
+        }
96
+
97
+        throw new IllegalIDChangeException('Not allowed to assign a new ID to an already saved comment.');
98
+    }
99
+
100
+    /**
101
+     * returns the parent ID of the comment
102
+     *
103
+     * @return string
104
+     * @since 9.0.0
105
+     */
106
+    public function getParentId() {
107
+        return $this->data['parentId'];
108
+    }
109
+
110
+    /**
111
+     * sets the parent ID and returns itself
112
+     *
113
+     * @param string $parentId
114
+     * @return IComment
115
+     * @since 9.0.0
116
+     */
117
+    public function setParentId($parentId) {
118
+        if(!is_string($parentId)) {
119
+            throw new \InvalidArgumentException('String expected.');
120
+        }
121
+        $this->data['parentId'] = trim($parentId);
122
+        return $this;
123
+    }
124
+
125
+    /**
126
+     * returns the topmost parent ID of the comment
127
+     *
128
+     * @return string
129
+     * @since 9.0.0
130
+     */
131
+    public function getTopmostParentId() {
132
+        return $this->data['topmostParentId'];
133
+    }
134
+
135
+
136
+    /**
137
+     * sets the topmost parent ID and returns itself
138
+     *
139
+     * @param string $id
140
+     * @return IComment
141
+     * @since 9.0.0
142
+     */
143
+    public function setTopmostParentId($id) {
144
+        if(!is_string($id)) {
145
+            throw new \InvalidArgumentException('String expected.');
146
+        }
147
+        $this->data['topmostParentId'] = trim($id);
148
+        return $this;
149
+    }
150
+
151
+    /**
152
+     * returns the number of children
153
+     *
154
+     * @return int
155
+     * @since 9.0.0
156
+     */
157
+    public function getChildrenCount() {
158
+        return $this->data['childrenCount'];
159
+    }
160
+
161
+    /**
162
+     * sets the number of children
163
+     *
164
+     * @param int $count
165
+     * @return IComment
166
+     * @since 9.0.0
167
+     */
168
+    public function setChildrenCount($count) {
169
+        if(!is_int($count)) {
170
+            throw new \InvalidArgumentException('Integer expected.');
171
+        }
172
+        $this->data['childrenCount'] = $count;
173
+        return $this;
174
+    }
175
+
176
+    /**
177
+     * returns the message of the comment
178
+     *
179
+     * @return string
180
+     * @since 9.0.0
181
+     */
182
+    public function getMessage() {
183
+        return $this->data['message'];
184
+    }
185
+
186
+    /**
187
+     * sets the message of the comment and returns itself
188
+     *
189
+     * @param string $message
190
+     * @return IComment
191
+     * @throws MessageTooLongException
192
+     * @since 9.0.0
193
+     */
194
+    public function setMessage($message) {
195
+        if(!is_string($message)) {
196
+            throw new \InvalidArgumentException('String expected.');
197
+        }
198
+        $message = trim($message);
199
+        if(mb_strlen($message, 'UTF-8') > IComment::MAX_MESSAGE_LENGTH) {
200
+            throw new MessageTooLongException('Comment message must not exceed ' . IComment::MAX_MESSAGE_LENGTH . ' characters');
201
+        }
202
+        $this->data['message'] = $message;
203
+        return $this;
204
+    }
205
+
206
+    /**
207
+     * returns an array containing mentions that are included in the comment
208
+     *
209
+     * @return array each mention provides a 'type' and an 'id', see example below
210
+     * @since 11.0.0
211
+     *
212
+     * The return array looks like:
213
+     * [
214
+     *   [
215
+     *     'type' => 'user',
216
+     *     'id' => 'citizen4'
217
+     *   ],
218
+     *   [
219
+     *     'type' => 'group',
220
+     *     'id' => 'media'
221
+     *   ],
222
+     *   …
223
+     * ]
224
+     *
225
+     */
226
+    public function getMentions() {
227
+        $ok = preg_match_all('/\B@[a-z0-9_\-@\.\']+/i', $this->getMessage(), $mentions);
228
+        if(!$ok || !isset($mentions[0]) || !is_array($mentions[0])) {
229
+            return [];
230
+        }
231
+        $uids = array_unique($mentions[0]);
232
+        $result = [];
233
+        foreach ($uids as $uid) {
234
+            // exclude author, no self-mentioning
235
+            if($uid === '@' . $this->getActorId()) {
236
+                continue;
237
+            }
238
+            $result[] = ['type' => 'user', 'id' => substr($uid, 1)];
239
+        }
240
+        return $result;
241
+    }
242
+
243
+    /**
244
+     * returns the verb of the comment
245
+     *
246
+     * @return string
247
+     * @since 9.0.0
248
+     */
249
+    public function getVerb() {
250
+        return $this->data['verb'];
251
+    }
252
+
253
+    /**
254
+     * sets the verb of the comment, e.g. 'comment' or 'like'
255
+     *
256
+     * @param string $verb
257
+     * @return IComment
258
+     * @since 9.0.0
259
+     */
260
+    public function setVerb($verb) {
261
+        if(!is_string($verb) || !trim($verb)) {
262
+            throw new \InvalidArgumentException('Non-empty String expected.');
263
+        }
264
+        $this->data['verb'] = trim($verb);
265
+        return $this;
266
+    }
267
+
268
+    /**
269
+     * returns the actor type
270
+     *
271
+     * @return string
272
+     * @since 9.0.0
273
+     */
274
+    public function getActorType() {
275
+        return $this->data['actorType'];
276
+    }
277
+
278
+    /**
279
+     * returns the actor ID
280
+     *
281
+     * @return string
282
+     * @since 9.0.0
283
+     */
284
+    public function getActorId() {
285
+        return $this->data['actorId'];
286
+    }
287
+
288
+    /**
289
+     * sets (overwrites) the actor type and id
290
+     *
291
+     * @param string $actorType e.g. 'users'
292
+     * @param string $actorId e.g. 'zombie234'
293
+     * @return IComment
294
+     * @since 9.0.0
295
+     */
296
+    public function setActor($actorType, $actorId) {
297
+        if(
298
+                !is_string($actorType) || !trim($actorType)
299
+            || !is_string($actorId)   || !trim($actorId)
300
+        ) {
301
+            throw new \InvalidArgumentException('String expected.');
302
+        }
303
+        $this->data['actorType'] = trim($actorType);
304
+        $this->data['actorId']   = trim($actorId);
305
+        return $this;
306
+    }
307
+
308
+    /**
309
+     * returns the creation date of the comment.
310
+     *
311
+     * If not explicitly set, it shall default to the time of initialization.
312
+     *
313
+     * @return \DateTime
314
+     * @since 9.0.0
315
+     */
316
+    public function getCreationDateTime() {
317
+        return $this->data['creationDT'];
318
+    }
319
+
320
+    /**
321
+     * sets the creation date of the comment and returns itself
322
+     *
323
+     * @param \DateTime $timestamp
324
+     * @return IComment
325
+     * @since 9.0.0
326
+     */
327
+    public function setCreationDateTime(\DateTime $timestamp) {
328
+        $this->data['creationDT'] = $timestamp;
329
+        return $this;
330
+    }
331
+
332
+    /**
333
+     * returns the DateTime of the most recent child, if set, otherwise null
334
+     *
335
+     * @return \DateTime|null
336
+     * @since 9.0.0
337
+     */
338
+    public function getLatestChildDateTime() {
339
+        return $this->data['latestChildDT'];
340
+    }
341
+
342
+    /**
343
+     * sets the date of the most recent child
344
+     *
345
+     * @param \DateTime $dateTime
346
+     * @return IComment
347
+     * @since 9.0.0
348
+     */
349
+    public function setLatestChildDateTime(\DateTime $dateTime = null) {
350
+        $this->data['latestChildDT'] = $dateTime;
351
+        return $this;
352
+    }
353
+
354
+    /**
355
+     * returns the object type the comment is attached to
356
+     *
357
+     * @return string
358
+     * @since 9.0.0
359
+     */
360
+    public function getObjectType() {
361
+        return $this->data['objectType'];
362
+    }
363
+
364
+    /**
365
+     * returns the object id the comment is attached to
366
+     *
367
+     * @return string
368
+     * @since 9.0.0
369
+     */
370
+    public function getObjectId() {
371
+        return $this->data['objectId'];
372
+    }
373
+
374
+    /**
375
+     * sets (overwrites) the object of the comment
376
+     *
377
+     * @param string $objectType e.g. 'files'
378
+     * @param string $objectId e.g. '16435'
379
+     * @return IComment
380
+     * @since 9.0.0
381
+     */
382
+    public function setObject($objectType, $objectId) {
383
+        if(
384
+                !is_string($objectType) || !trim($objectType)
385
+            || !is_string($objectId)   || !trim($objectId)
386
+        ) {
387
+            throw new \InvalidArgumentException('String expected.');
388
+        }
389
+        $this->data['objectType'] = trim($objectType);
390
+        $this->data['objectId']   = trim($objectId);
391
+        return $this;
392
+    }
393
+
394
+    /**
395
+     * sets the comment data based on an array with keys as taken from the
396
+     * database.
397
+     *
398
+     * @param array $data
399
+     * @return IComment
400
+     */
401
+    protected function fromArray($data) {
402
+        foreach(array_keys($data) as $key) {
403
+            // translate DB keys to internal setter names
404
+            $setter = 'set' . implode('', array_map('ucfirst', explode('_', $key)));
405
+            $setter = str_replace('Timestamp', 'DateTime', $setter);
406
+
407
+            if(method_exists($this, $setter)) {
408
+                $this->$setter($data[$key]);
409
+            }
410
+        }
411
+
412
+        foreach(['actor', 'object'] as $role) {
413
+            if(isset($data[$role . '_type']) && isset($data[$role . '_id'])) {
414
+                $setter = 'set' . ucfirst($role);
415
+                $this->$setter($data[$role . '_type'], $data[$role . '_id']);
416
+            }
417
+        }
418
+
419
+        return $this;
420
+    }
421 421
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * 						the comments database scheme
52 52
 	 */
53 53
 	public function __construct(array $data = null) {
54
-		if(is_array($data)) {
54
+		if (is_array($data)) {
55 55
 			$this->fromArray($data);
56 56
 		}
57 57
 	}
@@ -84,12 +84,12 @@  discard block
 block discarded – undo
84 84
 	 * @since 9.0.0
85 85
 	 */
86 86
 	public function setId($id) {
87
-		if(!is_string($id)) {
87
+		if (!is_string($id)) {
88 88
 			throw new \InvalidArgumentException('String expected.');
89 89
 		}
90 90
 
91 91
 		$id = trim($id);
92
-		if($this->data['id'] === '' || ($this->data['id'] !== '' && $id === '')) {
92
+		if ($this->data['id'] === '' || ($this->data['id'] !== '' && $id === '')) {
93 93
 			$this->data['id'] = $id;
94 94
 			return $this;
95 95
 		}
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 * @since 9.0.0
116 116
 	 */
117 117
 	public function setParentId($parentId) {
118
-		if(!is_string($parentId)) {
118
+		if (!is_string($parentId)) {
119 119
 			throw new \InvalidArgumentException('String expected.');
120 120
 		}
121 121
 		$this->data['parentId'] = trim($parentId);
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @since 9.0.0
142 142
 	 */
143 143
 	public function setTopmostParentId($id) {
144
-		if(!is_string($id)) {
144
+		if (!is_string($id)) {
145 145
 			throw new \InvalidArgumentException('String expected.');
146 146
 		}
147 147
 		$this->data['topmostParentId'] = trim($id);
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 * @since 9.0.0
167 167
 	 */
168 168
 	public function setChildrenCount($count) {
169
-		if(!is_int($count)) {
169
+		if (!is_int($count)) {
170 170
 			throw new \InvalidArgumentException('Integer expected.');
171 171
 		}
172 172
 		$this->data['childrenCount'] = $count;
@@ -192,12 +192,12 @@  discard block
 block discarded – undo
192 192
 	 * @since 9.0.0
193 193
 	 */
194 194
 	public function setMessage($message) {
195
-		if(!is_string($message)) {
195
+		if (!is_string($message)) {
196 196
 			throw new \InvalidArgumentException('String expected.');
197 197
 		}
198 198
 		$message = trim($message);
199
-		if(mb_strlen($message, 'UTF-8') > IComment::MAX_MESSAGE_LENGTH) {
200
-			throw new MessageTooLongException('Comment message must not exceed ' . IComment::MAX_MESSAGE_LENGTH . ' characters');
199
+		if (mb_strlen($message, 'UTF-8') > IComment::MAX_MESSAGE_LENGTH) {
200
+			throw new MessageTooLongException('Comment message must not exceed '.IComment::MAX_MESSAGE_LENGTH.' characters');
201 201
 		}
202 202
 		$this->data['message'] = $message;
203 203
 		return $this;
@@ -225,14 +225,14 @@  discard block
 block discarded – undo
225 225
 	 */
226 226
 	public function getMentions() {
227 227
 		$ok = preg_match_all('/\B@[a-z0-9_\-@\.\']+/i', $this->getMessage(), $mentions);
228
-		if(!$ok || !isset($mentions[0]) || !is_array($mentions[0])) {
228
+		if (!$ok || !isset($mentions[0]) || !is_array($mentions[0])) {
229 229
 			return [];
230 230
 		}
231 231
 		$uids = array_unique($mentions[0]);
232 232
 		$result = [];
233 233
 		foreach ($uids as $uid) {
234 234
 			// exclude author, no self-mentioning
235
-			if($uid === '@' . $this->getActorId()) {
235
+			if ($uid === '@'.$this->getActorId()) {
236 236
 				continue;
237 237
 			}
238 238
 			$result[] = ['type' => 'user', 'id' => substr($uid, 1)];
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	 * @since 9.0.0
259 259
 	 */
260 260
 	public function setVerb($verb) {
261
-		if(!is_string($verb) || !trim($verb)) {
261
+		if (!is_string($verb) || !trim($verb)) {
262 262
 			throw new \InvalidArgumentException('Non-empty String expected.');
263 263
 		}
264 264
 		$this->data['verb'] = trim($verb);
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
 	 * @since 9.0.0
295 295
 	 */
296 296
 	public function setActor($actorType, $actorId) {
297
-		if(
297
+		if (
298 298
 		       !is_string($actorType) || !trim($actorType)
299
-		    || !is_string($actorId)   || !trim($actorId)
299
+		    || !is_string($actorId) || !trim($actorId)
300 300
 		) {
301 301
 			throw new \InvalidArgumentException('String expected.');
302 302
 		}
@@ -380,9 +380,9 @@  discard block
 block discarded – undo
380 380
 	 * @since 9.0.0
381 381
 	 */
382 382
 	public function setObject($objectType, $objectId) {
383
-		if(
383
+		if (
384 384
 		       !is_string($objectType) || !trim($objectType)
385
-		    || !is_string($objectId)   || !trim($objectId)
385
+		    || !is_string($objectId) || !trim($objectId)
386 386
 		) {
387 387
 			throw new \InvalidArgumentException('String expected.');
388 388
 		}
@@ -399,20 +399,20 @@  discard block
 block discarded – undo
399 399
 	 * @return IComment
400 400
 	 */
401 401
 	protected function fromArray($data) {
402
-		foreach(array_keys($data) as $key) {
402
+		foreach (array_keys($data) as $key) {
403 403
 			// translate DB keys to internal setter names
404
-			$setter = 'set' . implode('', array_map('ucfirst', explode('_', $key)));
404
+			$setter = 'set'.implode('', array_map('ucfirst', explode('_', $key)));
405 405
 			$setter = str_replace('Timestamp', 'DateTime', $setter);
406 406
 
407
-			if(method_exists($this, $setter)) {
407
+			if (method_exists($this, $setter)) {
408 408
 				$this->$setter($data[$key]);
409 409
 			}
410 410
 		}
411 411
 
412
-		foreach(['actor', 'object'] as $role) {
413
-			if(isset($data[$role . '_type']) && isset($data[$role . '_id'])) {
414
-				$setter = 'set' . ucfirst($role);
415
-				$this->$setter($data[$role . '_type'], $data[$role . '_id']);
412
+		foreach (['actor', 'object'] as $role) {
413
+			if (isset($data[$role.'_type']) && isset($data[$role.'_id'])) {
414
+				$setter = 'set'.ucfirst($role);
415
+				$this->$setter($data[$role.'_type'], $data[$role.'_id']);
416 416
 			}
417 417
 		}
418 418
 
Please login to merge, or discard this patch.
lib/private/Notification/Notification.php 1 patch
Indentation   +551 added lines, -551 removed lines patch added patch discarded remove patch
@@ -31,555 +31,555 @@
 block discarded – undo
31 31
 
32 32
 class Notification implements INotification {
33 33
 
34
-	/** @var IValidator */
35
-	protected $richValidator;
36
-
37
-	/** @var string */
38
-	protected $app;
39
-
40
-	/** @var string */
41
-	protected $user;
42
-
43
-	/** @var \DateTime */
44
-	protected $dateTime;
45
-
46
-	/** @var string */
47
-	protected $objectType;
48
-
49
-	/** @var string */
50
-	protected $objectId;
51
-
52
-	/** @var string */
53
-	protected $subject;
54
-
55
-	/** @var array */
56
-	protected $subjectParameters;
57
-
58
-	/** @var string */
59
-	protected $subjectParsed;
60
-
61
-	/** @var string */
62
-	protected $subjectRich;
63
-
64
-	/** @var array */
65
-	protected $subjectRichParameters;
66
-
67
-	/** @var string */
68
-	protected $message;
69
-
70
-	/** @var array */
71
-	protected $messageParameters;
72
-
73
-	/** @var string */
74
-	protected $messageParsed;
75
-
76
-	/** @var string */
77
-	protected $messageRich;
78
-
79
-	/** @var array */
80
-	protected $messageRichParameters;
81
-
82
-	/** @var string */
83
-	protected $link;
84
-
85
-	/** @var string */
86
-	protected $icon;
87
-
88
-	/** @var array */
89
-	protected $actions;
90
-
91
-	/** @var array */
92
-	protected $actionsParsed;
93
-
94
-	/** @var bool */
95
-	protected $hasPrimaryAction;
96
-
97
-	/** @var bool */
98
-	protected $hasPrimaryParsedAction;
99
-
100
-	/**
101
-	 * Constructor
102
-	 *
103
-	 * @param IValidator $richValidator
104
-	 */
105
-	public function __construct(IValidator $richValidator) {
106
-		$this->richValidator = $richValidator;
107
-		$this->app = '';
108
-		$this->user = '';
109
-		$this->dateTime = new \DateTime();
110
-		$this->dateTime->setTimestamp(0);
111
-		$this->objectType = '';
112
-		$this->objectId = '';
113
-		$this->subject = '';
114
-		$this->subjectParameters = [];
115
-		$this->subjectParsed = '';
116
-		$this->subjectRich = '';
117
-		$this->subjectRichParameters = [];
118
-		$this->message = '';
119
-		$this->messageParameters = [];
120
-		$this->messageParsed = '';
121
-		$this->messageRich = '';
122
-		$this->messageRichParameters = [];
123
-		$this->link = '';
124
-		$this->icon = '';
125
-		$this->actions = [];
126
-		$this->actionsParsed = [];
127
-	}
128
-
129
-	/**
130
-	 * @param string $app
131
-	 * @return $this
132
-	 * @throws \InvalidArgumentException if the app id is invalid
133
-	 * @since 8.2.0
134
-	 */
135
-	public function setApp($app) {
136
-		if (!is_string($app) || $app === '' || isset($app[32])) {
137
-			throw new \InvalidArgumentException('The given app name is invalid');
138
-		}
139
-		$this->app = $app;
140
-		return $this;
141
-	}
142
-
143
-	/**
144
-	 * @return string
145
-	 * @since 8.2.0
146
-	 */
147
-	public function getApp() {
148
-		return $this->app;
149
-	}
150
-
151
-	/**
152
-	 * @param string $user
153
-	 * @return $this
154
-	 * @throws \InvalidArgumentException if the user id is invalid
155
-	 * @since 8.2.0
156
-	 */
157
-	public function setUser($user) {
158
-		if (!is_string($user) || $user === '' || isset($user[64])) {
159
-			throw new \InvalidArgumentException('The given user id is invalid');
160
-		}
161
-		$this->user = $user;
162
-		return $this;
163
-	}
164
-
165
-	/**
166
-	 * @return string
167
-	 * @since 8.2.0
168
-	 */
169
-	public function getUser() {
170
-		return $this->user;
171
-	}
172
-
173
-	/**
174
-	 * @param \DateTime $dateTime
175
-	 * @return $this
176
-	 * @throws \InvalidArgumentException if the $dateTime is invalid
177
-	 * @since 9.0.0
178
-	 */
179
-	public function setDateTime(\DateTime $dateTime) {
180
-		if ($dateTime->getTimestamp() === 0) {
181
-			throw new \InvalidArgumentException('The given date time is invalid');
182
-		}
183
-		$this->dateTime = $dateTime;
184
-		return $this;
185
-	}
186
-
187
-	/**
188
-	 * @return \DateTime
189
-	 * @since 9.0.0
190
-	 */
191
-	public function getDateTime() {
192
-		return $this->dateTime;
193
-	}
194
-
195
-	/**
196
-	 * @param string $type
197
-	 * @param string $id
198
-	 * @return $this
199
-	 * @throws \InvalidArgumentException if the object type or id is invalid
200
-	 * @since 8.2.0 - 9.0.0: Type of $id changed to string
201
-	 */
202
-	public function setObject($type, $id) {
203
-		if (!is_string($type) || $type === '' || isset($type[64])) {
204
-			throw new \InvalidArgumentException('The given object type is invalid');
205
-		}
206
-		$this->objectType = $type;
207
-
208
-		if (!is_int($id) && (!is_string($id) || $id === '' || isset($id[64]))) {
209
-			throw new \InvalidArgumentException('The given object id is invalid');
210
-		}
211
-		$this->objectId = (string) $id;
212
-		return $this;
213
-	}
214
-
215
-	/**
216
-	 * @return string
217
-	 * @since 8.2.0
218
-	 */
219
-	public function getObjectType() {
220
-		return $this->objectType;
221
-	}
222
-
223
-	/**
224
-	 * @return string
225
-	 * @since 8.2.0 - 9.0.0: Return type changed to string
226
-	 */
227
-	public function getObjectId() {
228
-		return $this->objectId;
229
-	}
230
-
231
-	/**
232
-	 * @param string $subject
233
-	 * @param array $parameters
234
-	 * @return $this
235
-	 * @throws \InvalidArgumentException if the subject or parameters are invalid
236
-	 * @since 8.2.0
237
-	 */
238
-	public function setSubject($subject, array $parameters = []) {
239
-		if (!is_string($subject) || $subject === '' || isset($subject[64])) {
240
-			throw new \InvalidArgumentException('The given subject is invalid');
241
-		}
242
-
243
-		$this->subject = $subject;
244
-		$this->subjectParameters = $parameters;
245
-
246
-		return $this;
247
-	}
248
-
249
-	/**
250
-	 * @return string
251
-	 * @since 8.2.0
252
-	 */
253
-	public function getSubject() {
254
-		return $this->subject;
255
-	}
256
-
257
-	/**
258
-	 * @return string[]
259
-	 * @since 8.2.0
260
-	 */
261
-	public function getSubjectParameters() {
262
-		return $this->subjectParameters;
263
-	}
264
-
265
-	/**
266
-	 * @param string $subject
267
-	 * @return $this
268
-	 * @throws \InvalidArgumentException if the subject is invalid
269
-	 * @since 8.2.0
270
-	 */
271
-	public function setParsedSubject($subject) {
272
-		if (!is_string($subject) || $subject === '') {
273
-			throw new \InvalidArgumentException('The given parsed subject is invalid');
274
-		}
275
-		$this->subjectParsed = $subject;
276
-		return $this;
277
-	}
278
-
279
-	/**
280
-	 * @return string
281
-	 * @since 8.2.0
282
-	 */
283
-	public function getParsedSubject() {
284
-		return $this->subjectParsed;
285
-	}
286
-
287
-	/**
288
-	 * @param string $subject
289
-	 * @param array $parameters
290
-	 * @return $this
291
-	 * @throws \InvalidArgumentException if the subject or parameters are invalid
292
-	 * @since 11.0.0
293
-	 */
294
-	public function setRichSubject($subject, array $parameters = []) {
295
-		if (!is_string($subject) || $subject === '') {
296
-			throw new \InvalidArgumentException('The given parsed subject is invalid');
297
-		}
298
-
299
-		$this->subjectRich = $subject;
300
-		$this->subjectRichParameters = $parameters;
301
-
302
-		return $this;
303
-	}
304
-
305
-	/**
306
-	 * @return string
307
-	 * @since 11.0.0
308
-	 */
309
-	public function getRichSubject() {
310
-		return $this->subjectRich;
311
-	}
312
-
313
-	/**
314
-	 * @return array[]
315
-	 * @since 11.0.0
316
-	 */
317
-	public function getRichSubjectParameters() {
318
-		return $this->subjectRichParameters;
319
-	}
320
-
321
-	/**
322
-	 * @param string $message
323
-	 * @param array $parameters
324
-	 * @return $this
325
-	 * @throws \InvalidArgumentException if the message or parameters are invalid
326
-	 * @since 8.2.0
327
-	 */
328
-	public function setMessage($message, array $parameters = []) {
329
-		if (!is_string($message) || $message === '' || isset($message[64])) {
330
-			throw new \InvalidArgumentException('The given message is invalid');
331
-		}
332
-
333
-		$this->message = $message;
334
-		$this->messageParameters = $parameters;
335
-
336
-		return $this;
337
-	}
338
-
339
-	/**
340
-	 * @return string
341
-	 * @since 8.2.0
342
-	 */
343
-	public function getMessage() {
344
-		return $this->message;
345
-	}
346
-
347
-	/**
348
-	 * @return string[]
349
-	 * @since 8.2.0
350
-	 */
351
-	public function getMessageParameters() {
352
-		return $this->messageParameters;
353
-	}
354
-
355
-	/**
356
-	 * @param string $message
357
-	 * @return $this
358
-	 * @throws \InvalidArgumentException if the message is invalid
359
-	 * @since 8.2.0
360
-	 */
361
-	public function setParsedMessage($message) {
362
-		if (!is_string($message) || $message === '') {
363
-			throw new \InvalidArgumentException('The given parsed message is invalid');
364
-		}
365
-		$this->messageParsed = $message;
366
-		return $this;
367
-	}
368
-
369
-	/**
370
-	 * @return string
371
-	 * @since 8.2.0
372
-	 */
373
-	public function getParsedMessage() {
374
-		return $this->messageParsed;
375
-	}
376
-
377
-	/**
378
-	 * @param string $message
379
-	 * @param array $parameters
380
-	 * @return $this
381
-	 * @throws \InvalidArgumentException if the message or parameters are invalid
382
-	 * @since 11.0.0
383
-	 */
384
-	public function setRichMessage($message, array $parameters = []) {
385
-		if (!is_string($message) || $message === '') {
386
-			throw new \InvalidArgumentException('The given parsed message is invalid');
387
-		}
388
-
389
-		$this->messageRich = $message;
390
-		$this->messageRichParameters = $parameters;
391
-
392
-		return $this;
393
-	}
394
-
395
-	/**
396
-	 * @return string
397
-	 * @since 11.0.0
398
-	 */
399
-	public function getRichMessage() {
400
-		return $this->messageRich;
401
-	}
402
-
403
-	/**
404
-	 * @return array[]
405
-	 * @since 11.0.0
406
-	 */
407
-	public function getRichMessageParameters() {
408
-		return $this->messageRichParameters;
409
-	}
410
-
411
-	/**
412
-	 * @param string $link
413
-	 * @return $this
414
-	 * @throws \InvalidArgumentException if the link is invalid
415
-	 * @since 8.2.0
416
-	 */
417
-	public function setLink($link) {
418
-		if (!is_string($link) || $link === '' || isset($link[4000])) {
419
-			throw new \InvalidArgumentException('The given link is invalid');
420
-		}
421
-		$this->link = $link;
422
-		return $this;
423
-	}
424
-
425
-	/**
426
-	 * @return string
427
-	 * @since 8.2.0
428
-	 */
429
-	public function getLink() {
430
-		return $this->link;
431
-	}
432
-
433
-	/**
434
-	 * @param string $icon
435
-	 * @return $this
436
-	 * @throws \InvalidArgumentException if the icon is invalid
437
-	 * @since 11.0.0
438
-	 */
439
-	public function setIcon($icon) {
440
-		if (!is_string($icon) || $icon === '' || isset($icon[4000])) {
441
-			throw new \InvalidArgumentException('The given icon is invalid');
442
-		}
443
-		$this->icon = $icon;
444
-		return $this;
445
-	}
446
-
447
-	/**
448
-	 * @return string
449
-	 * @since 11.0.0
450
-	 */
451
-	public function getIcon() {
452
-		return $this->icon;
453
-	}
454
-
455
-	/**
456
-	 * @return IAction
457
-	 * @since 8.2.0
458
-	 */
459
-	public function createAction() {
460
-		return new Action();
461
-	}
462
-
463
-	/**
464
-	 * @param IAction $action
465
-	 * @return $this
466
-	 * @throws \InvalidArgumentException if the action is invalid
467
-	 * @since 8.2.0
468
-	 */
469
-	public function addAction(IAction $action) {
470
-		if (!$action->isValid()) {
471
-			throw new \InvalidArgumentException('The given action is invalid');
472
-		}
473
-
474
-		if ($action->isPrimary()) {
475
-			if ($this->hasPrimaryAction) {
476
-				throw new \InvalidArgumentException('The notification already has a primary action');
477
-			}
478
-
479
-			$this->hasPrimaryAction = true;
480
-		}
481
-
482
-		$this->actions[] = $action;
483
-		return $this;
484
-	}
485
-
486
-	/**
487
-	 * @return IAction[]
488
-	 * @since 8.2.0
489
-	 */
490
-	public function getActions() {
491
-		return $this->actions;
492
-	}
493
-
494
-	/**
495
-	 * @param IAction $action
496
-	 * @return $this
497
-	 * @throws \InvalidArgumentException if the action is invalid
498
-	 * @since 8.2.0
499
-	 */
500
-	public function addParsedAction(IAction $action) {
501
-		if (!$action->isValidParsed()) {
502
-			throw new \InvalidArgumentException('The given parsed action is invalid');
503
-		}
504
-
505
-		if ($action->isPrimary()) {
506
-			if ($this->hasPrimaryParsedAction) {
507
-				throw new \InvalidArgumentException('The notification already has a primary action');
508
-			}
509
-
510
-			$this->hasPrimaryParsedAction = true;
511
-
512
-			// Make sure the primary action is always the first one
513
-			array_unshift($this->actionsParsed, $action);
514
-		} else {
515
-			$this->actionsParsed[] = $action;
516
-		}
517
-
518
-		return $this;
519
-	}
520
-
521
-	/**
522
-	 * @return IAction[]
523
-	 * @since 8.2.0
524
-	 */
525
-	public function getParsedActions() {
526
-		return $this->actionsParsed;
527
-	}
528
-
529
-	/**
530
-	 * @return bool
531
-	 * @since 8.2.0
532
-	 */
533
-	public function isValid() {
534
-		return
535
-			$this->isValidCommon()
536
-			&&
537
-			$this->getSubject() !== ''
538
-		;
539
-	}
540
-
541
-	/**
542
-	 * @return bool
543
-	 * @since 8.2.0
544
-	 */
545
-	public function isValidParsed() {
546
-		if ($this->getRichSubject() !== '' || !empty($this->getRichSubjectParameters())) {
547
-			try {
548
-				$this->richValidator->validate($this->getRichSubject(), $this->getRichSubjectParameters());
549
-			} catch (InvalidObjectExeption $e) {
550
-				return false;
551
-			}
552
-		}
553
-
554
-		if ($this->getRichMessage() !== '' || !empty($this->getRichMessageParameters())) {
555
-			try {
556
-				$this->richValidator->validate($this->getRichMessage(), $this->getRichMessageParameters());
557
-			} catch (InvalidObjectExeption $e) {
558
-				return false;
559
-			}
560
-		}
561
-
562
-		return
563
-			$this->isValidCommon()
564
-			&&
565
-			$this->getParsedSubject() !== ''
566
-		;
567
-	}
568
-
569
-	/**
570
-	 * @return bool
571
-	 */
572
-	protected function isValidCommon() {
573
-		return
574
-			$this->getApp() !== ''
575
-			&&
576
-			$this->getUser() !== ''
577
-			&&
578
-			$this->getDateTime()->getTimestamp() !== 0
579
-			&&
580
-			$this->getObjectType() !== ''
581
-			&&
582
-			$this->getObjectId() !== ''
583
-		;
584
-	}
34
+    /** @var IValidator */
35
+    protected $richValidator;
36
+
37
+    /** @var string */
38
+    protected $app;
39
+
40
+    /** @var string */
41
+    protected $user;
42
+
43
+    /** @var \DateTime */
44
+    protected $dateTime;
45
+
46
+    /** @var string */
47
+    protected $objectType;
48
+
49
+    /** @var string */
50
+    protected $objectId;
51
+
52
+    /** @var string */
53
+    protected $subject;
54
+
55
+    /** @var array */
56
+    protected $subjectParameters;
57
+
58
+    /** @var string */
59
+    protected $subjectParsed;
60
+
61
+    /** @var string */
62
+    protected $subjectRich;
63
+
64
+    /** @var array */
65
+    protected $subjectRichParameters;
66
+
67
+    /** @var string */
68
+    protected $message;
69
+
70
+    /** @var array */
71
+    protected $messageParameters;
72
+
73
+    /** @var string */
74
+    protected $messageParsed;
75
+
76
+    /** @var string */
77
+    protected $messageRich;
78
+
79
+    /** @var array */
80
+    protected $messageRichParameters;
81
+
82
+    /** @var string */
83
+    protected $link;
84
+
85
+    /** @var string */
86
+    protected $icon;
87
+
88
+    /** @var array */
89
+    protected $actions;
90
+
91
+    /** @var array */
92
+    protected $actionsParsed;
93
+
94
+    /** @var bool */
95
+    protected $hasPrimaryAction;
96
+
97
+    /** @var bool */
98
+    protected $hasPrimaryParsedAction;
99
+
100
+    /**
101
+     * Constructor
102
+     *
103
+     * @param IValidator $richValidator
104
+     */
105
+    public function __construct(IValidator $richValidator) {
106
+        $this->richValidator = $richValidator;
107
+        $this->app = '';
108
+        $this->user = '';
109
+        $this->dateTime = new \DateTime();
110
+        $this->dateTime->setTimestamp(0);
111
+        $this->objectType = '';
112
+        $this->objectId = '';
113
+        $this->subject = '';
114
+        $this->subjectParameters = [];
115
+        $this->subjectParsed = '';
116
+        $this->subjectRich = '';
117
+        $this->subjectRichParameters = [];
118
+        $this->message = '';
119
+        $this->messageParameters = [];
120
+        $this->messageParsed = '';
121
+        $this->messageRich = '';
122
+        $this->messageRichParameters = [];
123
+        $this->link = '';
124
+        $this->icon = '';
125
+        $this->actions = [];
126
+        $this->actionsParsed = [];
127
+    }
128
+
129
+    /**
130
+     * @param string $app
131
+     * @return $this
132
+     * @throws \InvalidArgumentException if the app id is invalid
133
+     * @since 8.2.0
134
+     */
135
+    public function setApp($app) {
136
+        if (!is_string($app) || $app === '' || isset($app[32])) {
137
+            throw new \InvalidArgumentException('The given app name is invalid');
138
+        }
139
+        $this->app = $app;
140
+        return $this;
141
+    }
142
+
143
+    /**
144
+     * @return string
145
+     * @since 8.2.0
146
+     */
147
+    public function getApp() {
148
+        return $this->app;
149
+    }
150
+
151
+    /**
152
+     * @param string $user
153
+     * @return $this
154
+     * @throws \InvalidArgumentException if the user id is invalid
155
+     * @since 8.2.0
156
+     */
157
+    public function setUser($user) {
158
+        if (!is_string($user) || $user === '' || isset($user[64])) {
159
+            throw new \InvalidArgumentException('The given user id is invalid');
160
+        }
161
+        $this->user = $user;
162
+        return $this;
163
+    }
164
+
165
+    /**
166
+     * @return string
167
+     * @since 8.2.0
168
+     */
169
+    public function getUser() {
170
+        return $this->user;
171
+    }
172
+
173
+    /**
174
+     * @param \DateTime $dateTime
175
+     * @return $this
176
+     * @throws \InvalidArgumentException if the $dateTime is invalid
177
+     * @since 9.0.0
178
+     */
179
+    public function setDateTime(\DateTime $dateTime) {
180
+        if ($dateTime->getTimestamp() === 0) {
181
+            throw new \InvalidArgumentException('The given date time is invalid');
182
+        }
183
+        $this->dateTime = $dateTime;
184
+        return $this;
185
+    }
186
+
187
+    /**
188
+     * @return \DateTime
189
+     * @since 9.0.0
190
+     */
191
+    public function getDateTime() {
192
+        return $this->dateTime;
193
+    }
194
+
195
+    /**
196
+     * @param string $type
197
+     * @param string $id
198
+     * @return $this
199
+     * @throws \InvalidArgumentException if the object type or id is invalid
200
+     * @since 8.2.0 - 9.0.0: Type of $id changed to string
201
+     */
202
+    public function setObject($type, $id) {
203
+        if (!is_string($type) || $type === '' || isset($type[64])) {
204
+            throw new \InvalidArgumentException('The given object type is invalid');
205
+        }
206
+        $this->objectType = $type;
207
+
208
+        if (!is_int($id) && (!is_string($id) || $id === '' || isset($id[64]))) {
209
+            throw new \InvalidArgumentException('The given object id is invalid');
210
+        }
211
+        $this->objectId = (string) $id;
212
+        return $this;
213
+    }
214
+
215
+    /**
216
+     * @return string
217
+     * @since 8.2.0
218
+     */
219
+    public function getObjectType() {
220
+        return $this->objectType;
221
+    }
222
+
223
+    /**
224
+     * @return string
225
+     * @since 8.2.0 - 9.0.0: Return type changed to string
226
+     */
227
+    public function getObjectId() {
228
+        return $this->objectId;
229
+    }
230
+
231
+    /**
232
+     * @param string $subject
233
+     * @param array $parameters
234
+     * @return $this
235
+     * @throws \InvalidArgumentException if the subject or parameters are invalid
236
+     * @since 8.2.0
237
+     */
238
+    public function setSubject($subject, array $parameters = []) {
239
+        if (!is_string($subject) || $subject === '' || isset($subject[64])) {
240
+            throw new \InvalidArgumentException('The given subject is invalid');
241
+        }
242
+
243
+        $this->subject = $subject;
244
+        $this->subjectParameters = $parameters;
245
+
246
+        return $this;
247
+    }
248
+
249
+    /**
250
+     * @return string
251
+     * @since 8.2.0
252
+     */
253
+    public function getSubject() {
254
+        return $this->subject;
255
+    }
256
+
257
+    /**
258
+     * @return string[]
259
+     * @since 8.2.0
260
+     */
261
+    public function getSubjectParameters() {
262
+        return $this->subjectParameters;
263
+    }
264
+
265
+    /**
266
+     * @param string $subject
267
+     * @return $this
268
+     * @throws \InvalidArgumentException if the subject is invalid
269
+     * @since 8.2.0
270
+     */
271
+    public function setParsedSubject($subject) {
272
+        if (!is_string($subject) || $subject === '') {
273
+            throw new \InvalidArgumentException('The given parsed subject is invalid');
274
+        }
275
+        $this->subjectParsed = $subject;
276
+        return $this;
277
+    }
278
+
279
+    /**
280
+     * @return string
281
+     * @since 8.2.0
282
+     */
283
+    public function getParsedSubject() {
284
+        return $this->subjectParsed;
285
+    }
286
+
287
+    /**
288
+     * @param string $subject
289
+     * @param array $parameters
290
+     * @return $this
291
+     * @throws \InvalidArgumentException if the subject or parameters are invalid
292
+     * @since 11.0.0
293
+     */
294
+    public function setRichSubject($subject, array $parameters = []) {
295
+        if (!is_string($subject) || $subject === '') {
296
+            throw new \InvalidArgumentException('The given parsed subject is invalid');
297
+        }
298
+
299
+        $this->subjectRich = $subject;
300
+        $this->subjectRichParameters = $parameters;
301
+
302
+        return $this;
303
+    }
304
+
305
+    /**
306
+     * @return string
307
+     * @since 11.0.0
308
+     */
309
+    public function getRichSubject() {
310
+        return $this->subjectRich;
311
+    }
312
+
313
+    /**
314
+     * @return array[]
315
+     * @since 11.0.0
316
+     */
317
+    public function getRichSubjectParameters() {
318
+        return $this->subjectRichParameters;
319
+    }
320
+
321
+    /**
322
+     * @param string $message
323
+     * @param array $parameters
324
+     * @return $this
325
+     * @throws \InvalidArgumentException if the message or parameters are invalid
326
+     * @since 8.2.0
327
+     */
328
+    public function setMessage($message, array $parameters = []) {
329
+        if (!is_string($message) || $message === '' || isset($message[64])) {
330
+            throw new \InvalidArgumentException('The given message is invalid');
331
+        }
332
+
333
+        $this->message = $message;
334
+        $this->messageParameters = $parameters;
335
+
336
+        return $this;
337
+    }
338
+
339
+    /**
340
+     * @return string
341
+     * @since 8.2.0
342
+     */
343
+    public function getMessage() {
344
+        return $this->message;
345
+    }
346
+
347
+    /**
348
+     * @return string[]
349
+     * @since 8.2.0
350
+     */
351
+    public function getMessageParameters() {
352
+        return $this->messageParameters;
353
+    }
354
+
355
+    /**
356
+     * @param string $message
357
+     * @return $this
358
+     * @throws \InvalidArgumentException if the message is invalid
359
+     * @since 8.2.0
360
+     */
361
+    public function setParsedMessage($message) {
362
+        if (!is_string($message) || $message === '') {
363
+            throw new \InvalidArgumentException('The given parsed message is invalid');
364
+        }
365
+        $this->messageParsed = $message;
366
+        return $this;
367
+    }
368
+
369
+    /**
370
+     * @return string
371
+     * @since 8.2.0
372
+     */
373
+    public function getParsedMessage() {
374
+        return $this->messageParsed;
375
+    }
376
+
377
+    /**
378
+     * @param string $message
379
+     * @param array $parameters
380
+     * @return $this
381
+     * @throws \InvalidArgumentException if the message or parameters are invalid
382
+     * @since 11.0.0
383
+     */
384
+    public function setRichMessage($message, array $parameters = []) {
385
+        if (!is_string($message) || $message === '') {
386
+            throw new \InvalidArgumentException('The given parsed message is invalid');
387
+        }
388
+
389
+        $this->messageRich = $message;
390
+        $this->messageRichParameters = $parameters;
391
+
392
+        return $this;
393
+    }
394
+
395
+    /**
396
+     * @return string
397
+     * @since 11.0.0
398
+     */
399
+    public function getRichMessage() {
400
+        return $this->messageRich;
401
+    }
402
+
403
+    /**
404
+     * @return array[]
405
+     * @since 11.0.0
406
+     */
407
+    public function getRichMessageParameters() {
408
+        return $this->messageRichParameters;
409
+    }
410
+
411
+    /**
412
+     * @param string $link
413
+     * @return $this
414
+     * @throws \InvalidArgumentException if the link is invalid
415
+     * @since 8.2.0
416
+     */
417
+    public function setLink($link) {
418
+        if (!is_string($link) || $link === '' || isset($link[4000])) {
419
+            throw new \InvalidArgumentException('The given link is invalid');
420
+        }
421
+        $this->link = $link;
422
+        return $this;
423
+    }
424
+
425
+    /**
426
+     * @return string
427
+     * @since 8.2.0
428
+     */
429
+    public function getLink() {
430
+        return $this->link;
431
+    }
432
+
433
+    /**
434
+     * @param string $icon
435
+     * @return $this
436
+     * @throws \InvalidArgumentException if the icon is invalid
437
+     * @since 11.0.0
438
+     */
439
+    public function setIcon($icon) {
440
+        if (!is_string($icon) || $icon === '' || isset($icon[4000])) {
441
+            throw new \InvalidArgumentException('The given icon is invalid');
442
+        }
443
+        $this->icon = $icon;
444
+        return $this;
445
+    }
446
+
447
+    /**
448
+     * @return string
449
+     * @since 11.0.0
450
+     */
451
+    public function getIcon() {
452
+        return $this->icon;
453
+    }
454
+
455
+    /**
456
+     * @return IAction
457
+     * @since 8.2.0
458
+     */
459
+    public function createAction() {
460
+        return new Action();
461
+    }
462
+
463
+    /**
464
+     * @param IAction $action
465
+     * @return $this
466
+     * @throws \InvalidArgumentException if the action is invalid
467
+     * @since 8.2.0
468
+     */
469
+    public function addAction(IAction $action) {
470
+        if (!$action->isValid()) {
471
+            throw new \InvalidArgumentException('The given action is invalid');
472
+        }
473
+
474
+        if ($action->isPrimary()) {
475
+            if ($this->hasPrimaryAction) {
476
+                throw new \InvalidArgumentException('The notification already has a primary action');
477
+            }
478
+
479
+            $this->hasPrimaryAction = true;
480
+        }
481
+
482
+        $this->actions[] = $action;
483
+        return $this;
484
+    }
485
+
486
+    /**
487
+     * @return IAction[]
488
+     * @since 8.2.0
489
+     */
490
+    public function getActions() {
491
+        return $this->actions;
492
+    }
493
+
494
+    /**
495
+     * @param IAction $action
496
+     * @return $this
497
+     * @throws \InvalidArgumentException if the action is invalid
498
+     * @since 8.2.0
499
+     */
500
+    public function addParsedAction(IAction $action) {
501
+        if (!$action->isValidParsed()) {
502
+            throw new \InvalidArgumentException('The given parsed action is invalid');
503
+        }
504
+
505
+        if ($action->isPrimary()) {
506
+            if ($this->hasPrimaryParsedAction) {
507
+                throw new \InvalidArgumentException('The notification already has a primary action');
508
+            }
509
+
510
+            $this->hasPrimaryParsedAction = true;
511
+
512
+            // Make sure the primary action is always the first one
513
+            array_unshift($this->actionsParsed, $action);
514
+        } else {
515
+            $this->actionsParsed[] = $action;
516
+        }
517
+
518
+        return $this;
519
+    }
520
+
521
+    /**
522
+     * @return IAction[]
523
+     * @since 8.2.0
524
+     */
525
+    public function getParsedActions() {
526
+        return $this->actionsParsed;
527
+    }
528
+
529
+    /**
530
+     * @return bool
531
+     * @since 8.2.0
532
+     */
533
+    public function isValid() {
534
+        return
535
+            $this->isValidCommon()
536
+            &&
537
+            $this->getSubject() !== ''
538
+        ;
539
+    }
540
+
541
+    /**
542
+     * @return bool
543
+     * @since 8.2.0
544
+     */
545
+    public function isValidParsed() {
546
+        if ($this->getRichSubject() !== '' || !empty($this->getRichSubjectParameters())) {
547
+            try {
548
+                $this->richValidator->validate($this->getRichSubject(), $this->getRichSubjectParameters());
549
+            } catch (InvalidObjectExeption $e) {
550
+                return false;
551
+            }
552
+        }
553
+
554
+        if ($this->getRichMessage() !== '' || !empty($this->getRichMessageParameters())) {
555
+            try {
556
+                $this->richValidator->validate($this->getRichMessage(), $this->getRichMessageParameters());
557
+            } catch (InvalidObjectExeption $e) {
558
+                return false;
559
+            }
560
+        }
561
+
562
+        return
563
+            $this->isValidCommon()
564
+            &&
565
+            $this->getParsedSubject() !== ''
566
+        ;
567
+    }
568
+
569
+    /**
570
+     * @return bool
571
+     */
572
+    protected function isValidCommon() {
573
+        return
574
+            $this->getApp() !== ''
575
+            &&
576
+            $this->getUser() !== ''
577
+            &&
578
+            $this->getDateTime()->getTimestamp() !== 0
579
+            &&
580
+            $this->getObjectType() !== ''
581
+            &&
582
+            $this->getObjectId() !== ''
583
+        ;
584
+    }
585 585
 }
Please login to merge, or discard this patch.
lib/private/Notification/Action.php 1 patch
Indentation   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -27,148 +27,148 @@
 block discarded – undo
27 27
 
28 28
 class Action implements IAction {
29 29
 
30
-	/** @var string */
31
-	protected $label;
32
-
33
-	/** @var string */
34
-	protected $labelParsed;
35
-
36
-	/** @var string */
37
-	protected $link;
38
-
39
-	/** @var string */
40
-	protected $requestType;
41
-
42
-	/** @var string */
43
-	protected $icon;
44
-
45
-	/** @var bool */
46
-	protected $primary;
47
-
48
-	/**
49
-	 * Constructor
50
-	 */
51
-	public function __construct() {
52
-		$this->label = '';
53
-		$this->labelParsed = '';
54
-		$this->link = '';
55
-		$this->requestType = '';
56
-		$this->primary = false;
57
-	}
58
-
59
-	/**
60
-	 * @param string $label
61
-	 * @return $this
62
-	 * @throws \InvalidArgumentException if the label is invalid
63
-	 * @since 8.2.0
64
-	 */
65
-	public function setLabel($label) {
66
-		if (!is_string($label) || $label === '' || isset($label[32])) {
67
-			throw new \InvalidArgumentException('The given label is invalid');
68
-		}
69
-		$this->label = $label;
70
-		return $this;
71
-	}
72
-
73
-	/**
74
-	 * @return string
75
-	 * @since 8.2.0
76
-	 */
77
-	public function getLabel() {
78
-		return $this->label;
79
-	}
80
-
81
-	/**
82
-	 * @param string $label
83
-	 * @return $this
84
-	 * @throws \InvalidArgumentException if the label is invalid
85
-	 * @since 8.2.0
86
-	 */
87
-	public function setParsedLabel($label) {
88
-		if (!is_string($label) || $label === '') {
89
-			throw new \InvalidArgumentException('The given parsed label is invalid');
90
-		}
91
-		$this->labelParsed = $label;
92
-		return $this;
93
-	}
94
-
95
-	/**
96
-	 * @return string
97
-	 * @since 8.2.0
98
-	 */
99
-	public function getParsedLabel() {
100
-		return $this->labelParsed;
101
-	}
102
-
103
-	/**
104
-	 * @param $primary bool
105
-	 * @return $this
106
-	 * @throws \InvalidArgumentException if $primary is invalid
107
-	 * @since 9.0.0
108
-	 */
109
-	public function setPrimary($primary) {
110
-		if (!is_bool($primary)) {
111
-			throw new \InvalidArgumentException('The given primary option is invalid');
112
-		}
113
-
114
-		$this->primary = $primary;
115
-		return $this;
116
-	}
117
-
118
-	/**
119
-	 * @return bool
120
-	 * @since 9.0.0
121
-	 */
122
-	public function isPrimary() {
123
-		return $this->primary;
124
-	}
125
-
126
-	/**
127
-	 * @param string $link
128
-	 * @param string $requestType
129
-	 * @return $this
130
-	 * @throws \InvalidArgumentException if the link is invalid
131
-	 * @since 8.2.0
132
-	 */
133
-	public function setLink($link, $requestType) {
134
-		if (!is_string($link) || $link === '' || isset($link[256])) {
135
-			throw new \InvalidArgumentException('The given link is invalid');
136
-		}
137
-		if (!in_array($requestType, ['GET', 'POST', 'PUT', 'DELETE'], true)) {
138
-			throw new \InvalidArgumentException('The given request type is invalid');
139
-		}
140
-		$this->link = $link;
141
-		$this->requestType = $requestType;
142
-		return $this;
143
-	}
144
-
145
-	/**
146
-	 * @return string
147
-	 * @since 8.2.0
148
-	 */
149
-	public function getLink() {
150
-		return $this->link;
151
-	}
152
-
153
-	/**
154
-	 * @return string
155
-	 * @since 8.2.0
156
-	 */
157
-	public function getRequestType() {
158
-		return $this->requestType;
159
-	}
160
-
161
-	/**
162
-	 * @return bool
163
-	 */
164
-	public function isValid() {
165
-		return $this->label !== '' && $this->link !== '';
166
-	}
167
-
168
-	/**
169
-	 * @return bool
170
-	 */
171
-	public function isValidParsed() {
172
-		return $this->labelParsed !== '' && $this->link !== '';
173
-	}
30
+    /** @var string */
31
+    protected $label;
32
+
33
+    /** @var string */
34
+    protected $labelParsed;
35
+
36
+    /** @var string */
37
+    protected $link;
38
+
39
+    /** @var string */
40
+    protected $requestType;
41
+
42
+    /** @var string */
43
+    protected $icon;
44
+
45
+    /** @var bool */
46
+    protected $primary;
47
+
48
+    /**
49
+     * Constructor
50
+     */
51
+    public function __construct() {
52
+        $this->label = '';
53
+        $this->labelParsed = '';
54
+        $this->link = '';
55
+        $this->requestType = '';
56
+        $this->primary = false;
57
+    }
58
+
59
+    /**
60
+     * @param string $label
61
+     * @return $this
62
+     * @throws \InvalidArgumentException if the label is invalid
63
+     * @since 8.2.0
64
+     */
65
+    public function setLabel($label) {
66
+        if (!is_string($label) || $label === '' || isset($label[32])) {
67
+            throw new \InvalidArgumentException('The given label is invalid');
68
+        }
69
+        $this->label = $label;
70
+        return $this;
71
+    }
72
+
73
+    /**
74
+     * @return string
75
+     * @since 8.2.0
76
+     */
77
+    public function getLabel() {
78
+        return $this->label;
79
+    }
80
+
81
+    /**
82
+     * @param string $label
83
+     * @return $this
84
+     * @throws \InvalidArgumentException if the label is invalid
85
+     * @since 8.2.0
86
+     */
87
+    public function setParsedLabel($label) {
88
+        if (!is_string($label) || $label === '') {
89
+            throw new \InvalidArgumentException('The given parsed label is invalid');
90
+        }
91
+        $this->labelParsed = $label;
92
+        return $this;
93
+    }
94
+
95
+    /**
96
+     * @return string
97
+     * @since 8.2.0
98
+     */
99
+    public function getParsedLabel() {
100
+        return $this->labelParsed;
101
+    }
102
+
103
+    /**
104
+     * @param $primary bool
105
+     * @return $this
106
+     * @throws \InvalidArgumentException if $primary is invalid
107
+     * @since 9.0.0
108
+     */
109
+    public function setPrimary($primary) {
110
+        if (!is_bool($primary)) {
111
+            throw new \InvalidArgumentException('The given primary option is invalid');
112
+        }
113
+
114
+        $this->primary = $primary;
115
+        return $this;
116
+    }
117
+
118
+    /**
119
+     * @return bool
120
+     * @since 9.0.0
121
+     */
122
+    public function isPrimary() {
123
+        return $this->primary;
124
+    }
125
+
126
+    /**
127
+     * @param string $link
128
+     * @param string $requestType
129
+     * @return $this
130
+     * @throws \InvalidArgumentException if the link is invalid
131
+     * @since 8.2.0
132
+     */
133
+    public function setLink($link, $requestType) {
134
+        if (!is_string($link) || $link === '' || isset($link[256])) {
135
+            throw new \InvalidArgumentException('The given link is invalid');
136
+        }
137
+        if (!in_array($requestType, ['GET', 'POST', 'PUT', 'DELETE'], true)) {
138
+            throw new \InvalidArgumentException('The given request type is invalid');
139
+        }
140
+        $this->link = $link;
141
+        $this->requestType = $requestType;
142
+        return $this;
143
+    }
144
+
145
+    /**
146
+     * @return string
147
+     * @since 8.2.0
148
+     */
149
+    public function getLink() {
150
+        return $this->link;
151
+    }
152
+
153
+    /**
154
+     * @return string
155
+     * @since 8.2.0
156
+     */
157
+    public function getRequestType() {
158
+        return $this->requestType;
159
+    }
160
+
161
+    /**
162
+     * @return bool
163
+     */
164
+    public function isValid() {
165
+        return $this->label !== '' && $this->link !== '';
166
+    }
167
+
168
+    /**
169
+     * @return bool
170
+     */
171
+    public function isValidParsed() {
172
+        return $this->labelParsed !== '' && $this->link !== '';
173
+    }
174 174
 }
Please login to merge, or discard this patch.
lib/private/Notification/Manager.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@
 block discarded – undo
146 146
 				throw new \InvalidArgumentException('The given notifier information is invalid');
147 147
 			}
148 148
 			if (isset($this->notifiersInfo[$notifier['id']])) {
149
-				throw new \InvalidArgumentException('The given notifier ID ' . $notifier['id'] . ' is already in use');
149
+				throw new \InvalidArgumentException('The given notifier ID '.$notifier['id'].' is already in use');
150 150
 			}
151 151
 			$this->notifiersInfo[$notifier['id']] = $notifier['name'];
152 152
 		}
Please login to merge, or discard this patch.
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -31,217 +31,217 @@
 block discarded – undo
31 31
 use OCP\RichObjectStrings\IValidator;
32 32
 
33 33
 class Manager implements IManager {
34
-	/** @var IValidator */
35
-	protected $validator;
36
-
37
-	/** @var IApp[] */
38
-	protected $apps;
39
-
40
-	/** @var INotifier[] */
41
-	protected $notifiers;
42
-
43
-	/** @var array[] */
44
-	protected $notifiersInfo;
45
-
46
-	/** @var \Closure[] */
47
-	protected $appsClosures;
48
-
49
-	/** @var \Closure[] */
50
-	protected $notifiersClosures;
51
-
52
-	/** @var \Closure[] */
53
-	protected $notifiersInfoClosures;
54
-
55
-	/**
56
-	 * Manager constructor.
57
-	 *
58
-	 * @param IValidator $validator
59
-	 */
60
-	public function __construct(IValidator $validator) {
61
-		$this->validator = $validator;
62
-		$this->apps = [];
63
-		$this->notifiers = [];
64
-		$this->notifiersInfo = [];
65
-		$this->appsClosures = [];
66
-		$this->notifiersClosures = [];
67
-		$this->notifiersInfoClosures = [];
68
-	}
69
-
70
-	/**
71
-	 * @param \Closure $service The service must implement IApp, otherwise a
72
-	 *                          \InvalidArgumentException is thrown later
73
-	 * @since 8.2.0
74
-	 */
75
-	public function registerApp(\Closure $service) {
76
-		$this->appsClosures[] = $service;
77
-		$this->apps = [];
78
-	}
79
-
80
-	/**
81
-	 * @param \Closure $service The service must implement INotifier, otherwise a
82
-	 *                          \InvalidArgumentException is thrown later
83
-	 * @param \Closure $info    An array with the keys 'id' and 'name' containing
84
-	 *                          the app id and the app name
85
-	 * @since 8.2.0 - Parameter $info was added in 9.0.0
86
-	 */
87
-	public function registerNotifier(\Closure $service, \Closure $info) {
88
-		$this->notifiersClosures[] = $service;
89
-		$this->notifiersInfoClosures[] = $info;
90
-		$this->notifiers = [];
91
-		$this->notifiersInfo = [];
92
-	}
93
-
94
-	/**
95
-	 * @return IApp[]
96
-	 */
97
-	protected function getApps() {
98
-		if (!empty($this->apps)) {
99
-			return $this->apps;
100
-		}
101
-
102
-		$this->apps = [];
103
-		foreach ($this->appsClosures as $closure) {
104
-			$app = $closure();
105
-			if (!($app instanceof IApp)) {
106
-				throw new \InvalidArgumentException('The given notification app does not implement the IApp interface');
107
-			}
108
-			$this->apps[] = $app;
109
-		}
110
-
111
-		return $this->apps;
112
-	}
113
-
114
-	/**
115
-	 * @return INotifier[]
116
-	 */
117
-	protected function getNotifiers() {
118
-		if (!empty($this->notifiers)) {
119
-			return $this->notifiers;
120
-		}
121
-
122
-		$this->notifiers = [];
123
-		foreach ($this->notifiersClosures as $closure) {
124
-			$notifier = $closure();
125
-			if (!($notifier instanceof INotifier)) {
126
-				throw new \InvalidArgumentException('The given notifier does not implement the INotifier interface');
127
-			}
128
-			$this->notifiers[] = $notifier;
129
-		}
130
-
131
-		return $this->notifiers;
132
-	}
133
-
134
-	/**
135
-	 * @return array[]
136
-	 */
137
-	public function listNotifiers() {
138
-		if (!empty($this->notifiersInfo)) {
139
-			return $this->notifiersInfo;
140
-		}
141
-
142
-		$this->notifiersInfo = [];
143
-		foreach ($this->notifiersInfoClosures as $closure) {
144
-			$notifier = $closure();
145
-			if (!is_array($notifier) || count($notifier) !== 2 || !isset($notifier['id']) || !isset($notifier['name'])) {
146
-				throw new \InvalidArgumentException('The given notifier information is invalid');
147
-			}
148
-			if (isset($this->notifiersInfo[$notifier['id']])) {
149
-				throw new \InvalidArgumentException('The given notifier ID ' . $notifier['id'] . ' is already in use');
150
-			}
151
-			$this->notifiersInfo[$notifier['id']] = $notifier['name'];
152
-		}
153
-
154
-		return $this->notifiersInfo;
155
-	}
156
-
157
-	/**
158
-	 * @return INotification
159
-	 * @since 8.2.0
160
-	 */
161
-	public function createNotification() {
162
-		return new Notification($this->validator);
163
-	}
164
-
165
-	/**
166
-	 * @return bool
167
-	 * @since 8.2.0
168
-	 */
169
-	public function hasNotifiers() {
170
-		return !empty($this->notifiersClosures);
171
-	}
172
-
173
-	/**
174
-	 * @param INotification $notification
175
-	 * @throws \InvalidArgumentException When the notification is not valid
176
-	 * @since 8.2.0
177
-	 */
178
-	public function notify(INotification $notification) {
179
-		if (!$notification->isValid()) {
180
-			throw new \InvalidArgumentException('The given notification is invalid');
181
-		}
182
-
183
-		$apps = $this->getApps();
184
-
185
-		foreach ($apps as $app) {
186
-			try {
187
-				$app->notify($notification);
188
-			} catch (\InvalidArgumentException $e) {
189
-			}
190
-		}
191
-	}
192
-
193
-	/**
194
-	 * @param INotification $notification
195
-	 * @param string $languageCode The code of the language that should be used to prepare the notification
196
-	 * @return INotification
197
-	 * @throws \InvalidArgumentException When the notification was not prepared by a notifier
198
-	 * @since 8.2.0
199
-	 */
200
-	public function prepare(INotification $notification, $languageCode) {
201
-		$notifiers = $this->getNotifiers();
202
-
203
-		foreach ($notifiers as $notifier) {
204
-			try {
205
-				$notification = $notifier->prepare($notification, $languageCode);
206
-			} catch (\InvalidArgumentException $e) {
207
-				continue;
208
-			}
209
-
210
-			if (!($notification instanceof INotification) || !$notification->isValidParsed()) {
211
-				throw new \InvalidArgumentException('The given notification has not been handled');
212
-			}
213
-		}
214
-
215
-		if (!($notification instanceof INotification) || !$notification->isValidParsed()) {
216
-			throw new \InvalidArgumentException('The given notification has not been handled');
217
-		}
218
-
219
-		return $notification;
220
-	}
221
-
222
-	/**
223
-	 * @param INotification $notification
224
-	 */
225
-	public function markProcessed(INotification $notification) {
226
-		$apps = $this->getApps();
227
-
228
-		foreach ($apps as $app) {
229
-			$app->markProcessed($notification);
230
-		}
231
-	}
232
-
233
-	/**
234
-	 * @param INotification $notification
235
-	 * @return int
236
-	 */
237
-	public function getCount(INotification $notification) {
238
-		$apps = $this->getApps();
239
-
240
-		$count = 0;
241
-		foreach ($apps as $app) {
242
-			$count += $app->getCount($notification);
243
-		}
244
-
245
-		return $count;
246
-	}
34
+    /** @var IValidator */
35
+    protected $validator;
36
+
37
+    /** @var IApp[] */
38
+    protected $apps;
39
+
40
+    /** @var INotifier[] */
41
+    protected $notifiers;
42
+
43
+    /** @var array[] */
44
+    protected $notifiersInfo;
45
+
46
+    /** @var \Closure[] */
47
+    protected $appsClosures;
48
+
49
+    /** @var \Closure[] */
50
+    protected $notifiersClosures;
51
+
52
+    /** @var \Closure[] */
53
+    protected $notifiersInfoClosures;
54
+
55
+    /**
56
+     * Manager constructor.
57
+     *
58
+     * @param IValidator $validator
59
+     */
60
+    public function __construct(IValidator $validator) {
61
+        $this->validator = $validator;
62
+        $this->apps = [];
63
+        $this->notifiers = [];
64
+        $this->notifiersInfo = [];
65
+        $this->appsClosures = [];
66
+        $this->notifiersClosures = [];
67
+        $this->notifiersInfoClosures = [];
68
+    }
69
+
70
+    /**
71
+     * @param \Closure $service The service must implement IApp, otherwise a
72
+     *                          \InvalidArgumentException is thrown later
73
+     * @since 8.2.0
74
+     */
75
+    public function registerApp(\Closure $service) {
76
+        $this->appsClosures[] = $service;
77
+        $this->apps = [];
78
+    }
79
+
80
+    /**
81
+     * @param \Closure $service The service must implement INotifier, otherwise a
82
+     *                          \InvalidArgumentException is thrown later
83
+     * @param \Closure $info    An array with the keys 'id' and 'name' containing
84
+     *                          the app id and the app name
85
+     * @since 8.2.0 - Parameter $info was added in 9.0.0
86
+     */
87
+    public function registerNotifier(\Closure $service, \Closure $info) {
88
+        $this->notifiersClosures[] = $service;
89
+        $this->notifiersInfoClosures[] = $info;
90
+        $this->notifiers = [];
91
+        $this->notifiersInfo = [];
92
+    }
93
+
94
+    /**
95
+     * @return IApp[]
96
+     */
97
+    protected function getApps() {
98
+        if (!empty($this->apps)) {
99
+            return $this->apps;
100
+        }
101
+
102
+        $this->apps = [];
103
+        foreach ($this->appsClosures as $closure) {
104
+            $app = $closure();
105
+            if (!($app instanceof IApp)) {
106
+                throw new \InvalidArgumentException('The given notification app does not implement the IApp interface');
107
+            }
108
+            $this->apps[] = $app;
109
+        }
110
+
111
+        return $this->apps;
112
+    }
113
+
114
+    /**
115
+     * @return INotifier[]
116
+     */
117
+    protected function getNotifiers() {
118
+        if (!empty($this->notifiers)) {
119
+            return $this->notifiers;
120
+        }
121
+
122
+        $this->notifiers = [];
123
+        foreach ($this->notifiersClosures as $closure) {
124
+            $notifier = $closure();
125
+            if (!($notifier instanceof INotifier)) {
126
+                throw new \InvalidArgumentException('The given notifier does not implement the INotifier interface');
127
+            }
128
+            $this->notifiers[] = $notifier;
129
+        }
130
+
131
+        return $this->notifiers;
132
+    }
133
+
134
+    /**
135
+     * @return array[]
136
+     */
137
+    public function listNotifiers() {
138
+        if (!empty($this->notifiersInfo)) {
139
+            return $this->notifiersInfo;
140
+        }
141
+
142
+        $this->notifiersInfo = [];
143
+        foreach ($this->notifiersInfoClosures as $closure) {
144
+            $notifier = $closure();
145
+            if (!is_array($notifier) || count($notifier) !== 2 || !isset($notifier['id']) || !isset($notifier['name'])) {
146
+                throw new \InvalidArgumentException('The given notifier information is invalid');
147
+            }
148
+            if (isset($this->notifiersInfo[$notifier['id']])) {
149
+                throw new \InvalidArgumentException('The given notifier ID ' . $notifier['id'] . ' is already in use');
150
+            }
151
+            $this->notifiersInfo[$notifier['id']] = $notifier['name'];
152
+        }
153
+
154
+        return $this->notifiersInfo;
155
+    }
156
+
157
+    /**
158
+     * @return INotification
159
+     * @since 8.2.0
160
+     */
161
+    public function createNotification() {
162
+        return new Notification($this->validator);
163
+    }
164
+
165
+    /**
166
+     * @return bool
167
+     * @since 8.2.0
168
+     */
169
+    public function hasNotifiers() {
170
+        return !empty($this->notifiersClosures);
171
+    }
172
+
173
+    /**
174
+     * @param INotification $notification
175
+     * @throws \InvalidArgumentException When the notification is not valid
176
+     * @since 8.2.0
177
+     */
178
+    public function notify(INotification $notification) {
179
+        if (!$notification->isValid()) {
180
+            throw new \InvalidArgumentException('The given notification is invalid');
181
+        }
182
+
183
+        $apps = $this->getApps();
184
+
185
+        foreach ($apps as $app) {
186
+            try {
187
+                $app->notify($notification);
188
+            } catch (\InvalidArgumentException $e) {
189
+            }
190
+        }
191
+    }
192
+
193
+    /**
194
+     * @param INotification $notification
195
+     * @param string $languageCode The code of the language that should be used to prepare the notification
196
+     * @return INotification
197
+     * @throws \InvalidArgumentException When the notification was not prepared by a notifier
198
+     * @since 8.2.0
199
+     */
200
+    public function prepare(INotification $notification, $languageCode) {
201
+        $notifiers = $this->getNotifiers();
202
+
203
+        foreach ($notifiers as $notifier) {
204
+            try {
205
+                $notification = $notifier->prepare($notification, $languageCode);
206
+            } catch (\InvalidArgumentException $e) {
207
+                continue;
208
+            }
209
+
210
+            if (!($notification instanceof INotification) || !$notification->isValidParsed()) {
211
+                throw new \InvalidArgumentException('The given notification has not been handled');
212
+            }
213
+        }
214
+
215
+        if (!($notification instanceof INotification) || !$notification->isValidParsed()) {
216
+            throw new \InvalidArgumentException('The given notification has not been handled');
217
+        }
218
+
219
+        return $notification;
220
+    }
221
+
222
+    /**
223
+     * @param INotification $notification
224
+     */
225
+    public function markProcessed(INotification $notification) {
226
+        $apps = $this->getApps();
227
+
228
+        foreach ($apps as $app) {
229
+            $app->markProcessed($notification);
230
+        }
231
+    }
232
+
233
+    /**
234
+     * @param INotification $notification
235
+     * @return int
236
+     */
237
+    public function getCount(INotification $notification) {
238
+        $apps = $this->getApps();
239
+
240
+        $count = 0;
241
+        foreach ($apps as $app) {
242
+            $count += $app->getCount($notification);
243
+        }
244
+
245
+        return $count;
246
+    }
247 247
 }
Please login to merge, or discard this patch.
lib/private/IntegrityCheck/Iterator/ExcludeFileByNameFilterIterator.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -30,32 +30,32 @@
 block discarded – undo
30 30
  * @package OC\Integritycheck\Iterator
31 31
  */
32 32
 class ExcludeFileByNameFilterIterator extends \RecursiveFilterIterator {
33
-	/**
34
-	 * Array of excluded file names. Those are not scanned by the integrity checker.
35
-	 * This is used to exclude files which administrators could upload by mistakes
36
-	 * such as .DS_Store files.
37
-	 *
38
-	 * @var array
39
-	 */
40
-	private $excludedFilenames = [
41
-		'.DS_Store', // Mac OS X
42
-		'Thumbs.db', // Microsoft Windows
43
-		'.directory', // Dolphin (KDE)
44
-		'.webapp', // Gentoo/Funtoo & derivatives use a tool known as webapp-config to manager wep-apps.
45
-	];
33
+    /**
34
+     * Array of excluded file names. Those are not scanned by the integrity checker.
35
+     * This is used to exclude files which administrators could upload by mistakes
36
+     * such as .DS_Store files.
37
+     *
38
+     * @var array
39
+     */
40
+    private $excludedFilenames = [
41
+        '.DS_Store', // Mac OS X
42
+        'Thumbs.db', // Microsoft Windows
43
+        '.directory', // Dolphin (KDE)
44
+        '.webapp', // Gentoo/Funtoo & derivatives use a tool known as webapp-config to manager wep-apps.
45
+    ];
46 46
 
47
-	/**
48
-	 * @return bool
49
-	 */
50
-	public function accept() {
51
-		if($this->isDir()) {
52
-			return true;
53
-		}
47
+    /**
48
+     * @return bool
49
+     */
50
+    public function accept() {
51
+        if($this->isDir()) {
52
+            return true;
53
+        }
54 54
 
55
-		return !in_array(
56
-			$this->current()->getFilename(),
57
-			$this->excludedFilenames,
58
-			true
59
-		);
60
-	}
55
+        return !in_array(
56
+            $this->current()->getFilename(),
57
+            $this->excludedFilenames,
58
+            true
59
+        );
60
+    }
61 61
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
 	 * @return bool
49 49
 	 */
50 50
 	public function accept() {
51
-		if($this->isDir()) {
51
+		if ($this->isDir()) {
52 52
 			return true;
53 53
 		}
54 54
 
Please login to merge, or discard this patch.
lib/private/IntegrityCheck/Iterator/ExcludeFoldersByPathFilterIterator.php 2 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -24,45 +24,45 @@
 block discarded – undo
24 24
 namespace OC\IntegrityCheck\Iterator;
25 25
 
26 26
 class ExcludeFoldersByPathFilterIterator extends \RecursiveFilterIterator {
27
-	private $excludedFolders = [];
27
+    private $excludedFolders = [];
28 28
 
29
-	public function __construct(\RecursiveIterator $iterator, $root = '') {
30
-		parent::__construct($iterator);
29
+    public function __construct(\RecursiveIterator $iterator, $root = '') {
30
+        parent::__construct($iterator);
31 31
 
32
-		$appFolders = \OC::$APPSROOTS;
33
-		foreach($appFolders as $key => $appFolder) {
34
-			$appFolders[$key] = rtrim($appFolder['path'], '/');
35
-		}
32
+        $appFolders = \OC::$APPSROOTS;
33
+        foreach($appFolders as $key => $appFolder) {
34
+            $appFolders[$key] = rtrim($appFolder['path'], '/');
35
+        }
36 36
 
37
-		$excludedFolders = [
38
-			rtrim($root . '/data', '/'),
39
-			rtrim($root . '/themes', '/'),
40
-			rtrim($root . '/config', '/'),
41
-			rtrim($root . '/apps', '/'),
42
-			rtrim($root . '/assets', '/'),
43
-			rtrim($root . '/lost+found', '/'),
44
-			// Ignore folders generated by updater since the updater is replaced
45
-			// after the integrity check is run.
46
-			// See https://github.com/owncloud/updater/issues/318#issuecomment-212497846
47
-			rtrim($root . '/updater', '/'),
48
-			rtrim($root . '/_oc_upgrade', '/'),
49
-		];
50
-		$customDataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', '');
51
-		if($customDataDir !== '') {
52
-			$excludedFolders[] = rtrim($customDataDir, '/');
53
-		}
37
+        $excludedFolders = [
38
+            rtrim($root . '/data', '/'),
39
+            rtrim($root . '/themes', '/'),
40
+            rtrim($root . '/config', '/'),
41
+            rtrim($root . '/apps', '/'),
42
+            rtrim($root . '/assets', '/'),
43
+            rtrim($root . '/lost+found', '/'),
44
+            // Ignore folders generated by updater since the updater is replaced
45
+            // after the integrity check is run.
46
+            // See https://github.com/owncloud/updater/issues/318#issuecomment-212497846
47
+            rtrim($root . '/updater', '/'),
48
+            rtrim($root . '/_oc_upgrade', '/'),
49
+        ];
50
+        $customDataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', '');
51
+        if($customDataDir !== '') {
52
+            $excludedFolders[] = rtrim($customDataDir, '/');
53
+        }
54 54
 
55
-		$this->excludedFolders = array_merge($excludedFolders, $appFolders);
56
-	}
55
+        $this->excludedFolders = array_merge($excludedFolders, $appFolders);
56
+    }
57 57
 
58
-	/**
59
-	 * @return bool
60
-	 */
61
-	public function accept() {
62
-		return !in_array(
63
-			$this->current()->getPathName(),
64
-			$this->excludedFolders,
65
-			true
66
-		);
67
-	}
58
+    /**
59
+     * @return bool
60
+     */
61
+    public function accept() {
62
+        return !in_array(
63
+            $this->current()->getPathName(),
64
+            $this->excludedFolders,
65
+            true
66
+        );
67
+    }
68 68
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -30,25 +30,25 @@
 block discarded – undo
30 30
 		parent::__construct($iterator);
31 31
 
32 32
 		$appFolders = \OC::$APPSROOTS;
33
-		foreach($appFolders as $key => $appFolder) {
33
+		foreach ($appFolders as $key => $appFolder) {
34 34
 			$appFolders[$key] = rtrim($appFolder['path'], '/');
35 35
 		}
36 36
 
37 37
 		$excludedFolders = [
38
-			rtrim($root . '/data', '/'),
39
-			rtrim($root . '/themes', '/'),
40
-			rtrim($root . '/config', '/'),
41
-			rtrim($root . '/apps', '/'),
42
-			rtrim($root . '/assets', '/'),
43
-			rtrim($root . '/lost+found', '/'),
38
+			rtrim($root.'/data', '/'),
39
+			rtrim($root.'/themes', '/'),
40
+			rtrim($root.'/config', '/'),
41
+			rtrim($root.'/apps', '/'),
42
+			rtrim($root.'/assets', '/'),
43
+			rtrim($root.'/lost+found', '/'),
44 44
 			// Ignore folders generated by updater since the updater is replaced
45 45
 			// after the integrity check is run.
46 46
 			// See https://github.com/owncloud/updater/issues/318#issuecomment-212497846
47
-			rtrim($root . '/updater', '/'),
48
-			rtrim($root . '/_oc_upgrade', '/'),
47
+			rtrim($root.'/updater', '/'),
48
+			rtrim($root.'/_oc_upgrade', '/'),
49 49
 		];
50 50
 		$customDataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', '');
51
-		if($customDataDir !== '') {
51
+		if ($customDataDir !== '') {
52 52
 			$excludedFolders[] = rtrim($customDataDir, '/');
53 53
 		}
54 54
 
Please login to merge, or discard this patch.
lib/private/IntegrityCheck/Helpers/EnvironmentHelper.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -29,21 +29,21 @@
 block discarded – undo
29 29
  * @package OC\IntegrityCheck\Helpers
30 30
  */
31 31
 class EnvironmentHelper {
32
-	/**
33
-	 * Provides \OC::$SERVERROOT
34
-	 *
35
-	 * @return string
36
-	 */
37
-	public function getServerRoot() {
38
-		return rtrim(\OC::$SERVERROOT, '/');
39
-	}
32
+    /**
33
+     * Provides \OC::$SERVERROOT
34
+     *
35
+     * @return string
36
+     */
37
+    public function getServerRoot() {
38
+        return rtrim(\OC::$SERVERROOT, '/');
39
+    }
40 40
 
41
-	/**
42
-	 * Provides \OC_Util::getChannel()
43
-	 *
44
-	 * @return string
45
-	 */
46
-	public function getChannel() {
47
-		return \OC_Util::getChannel();
48
-	}
41
+    /**
42
+     * Provides \OC_Util::getChannel()
43
+     *
44
+     * @return string
45
+     */
46
+    public function getChannel() {
47
+        return \OC_Util::getChannel();
48
+    }
49 49
 }
Please login to merge, or discard this patch.