Passed
Push — master ( 27fb46...dad31c )
by rakekniven
15:02 queued 12s
created
lib/public/Util.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -304,9 +304,9 @@
 block discarded – undo
304 304
 	 */
305 305
 	public static function linkToRemote($service) {
306 306
 		$urlGenerator = \OC::$server->getURLGenerator();
307
-		$remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service;
307
+		$remoteBase = $urlGenerator->linkTo('', 'remote.php').'/'.$service;
308 308
 		return $urlGenerator->getAbsoluteURL(
309
-			$remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '')
309
+			$remoteBase.(($service[strlen($service) - 1] != '/') ? '/' : '')
310 310
 		);
311 311
 	}
312 312
 
Please login to merge, or discard this patch.
Indentation   +462 added lines, -462 removed lines patch added patch discarded remove patch
@@ -59,466 +59,466 @@
 block discarded – undo
59 59
  * @since 4.0.0
60 60
  */
61 61
 class Util {
62
-	/**
63
-	 * @deprecated 14.0.0 use \OCP\ILogger::DEBUG
64
-	 */
65
-	public const DEBUG = 0;
66
-	/**
67
-	 * @deprecated 14.0.0 use \OCP\ILogger::INFO
68
-	 */
69
-	public const INFO = 1;
70
-	/**
71
-	 * @deprecated 14.0.0 use \OCP\ILogger::WARN
72
-	 */
73
-	public const WARN = 2;
74
-	/**
75
-	 * @deprecated 14.0.0 use \OCP\ILogger::ERROR
76
-	 */
77
-	public const ERROR = 3;
78
-	/**
79
-	 * @deprecated 14.0.0 use \OCP\ILogger::FATAL
80
-	 */
81
-	public const FATAL = 4;
82
-
83
-	/** \OCP\Share\IManager */
84
-	private static $shareManager;
85
-
86
-	/**
87
-	 * get the current installed version of Nextcloud
88
-	 * @return array
89
-	 * @since 4.0.0
90
-	 */
91
-	public static function getVersion() {
92
-		return \OC_Util::getVersion();
93
-	}
94
-
95
-	/**
96
-	 * @since 17.0.0
97
-	 */
98
-	public static function hasExtendedSupport(): bool {
99
-		try {
100
-			/** @var \OCP\Support\Subscription\IRegistry */
101
-			$subscriptionRegistry = \OC::$server->query(\OCP\Support\Subscription\IRegistry::class);
102
-			return $subscriptionRegistry->delegateHasExtendedSupport();
103
-		} catch (AppFramework\QueryException $e) {
104
-		}
105
-		return \OC::$server->getConfig()->getSystemValueBool('extendedSupport', false);
106
-	}
107
-
108
-	/**
109
-	 * Set current update channel
110
-	 * @param string $channel
111
-	 * @since 8.1.0
112
-	 */
113
-	public static function setChannel($channel) {
114
-		\OC::$server->getConfig()->setSystemValue('updater.release.channel', $channel);
115
-	}
116
-
117
-	/**
118
-	 * Get current update channel
119
-	 * @return string
120
-	 * @since 8.1.0
121
-	 */
122
-	public static function getChannel() {
123
-		return \OC_Util::getChannel();
124
-	}
125
-
126
-	/**
127
-	 * write a message in the log
128
-	 * @param string $app
129
-	 * @param string $message
130
-	 * @param int $level
131
-	 * @since 4.0.0
132
-	 * @deprecated 13.0.0 use log of \OCP\ILogger
133
-	 */
134
-	public static function writeLog($app, $message, $level) {
135
-		$context = ['app' => $app];
136
-		\OC::$server->getLogger()->log($level, $message, $context);
137
-	}
138
-
139
-	/**
140
-	 * check if sharing is disabled for the current user
141
-	 *
142
-	 * @return boolean
143
-	 * @since 7.0.0
144
-	 * @deprecated 9.1.0 Use \OC::$server->getShareManager()->sharingDisabledForUser
145
-	 */
146
-	public static function isSharingDisabledForUser() {
147
-		if (self::$shareManager === null) {
148
-			self::$shareManager = \OC::$server->getShareManager();
149
-		}
150
-
151
-		$user = \OC::$server->getUserSession()->getUser();
152
-		if ($user !== null) {
153
-			$user = $user->getUID();
154
-		}
155
-
156
-		return self::$shareManager->sharingDisabledForUser($user);
157
-	}
158
-
159
-	/**
160
-	 * get l10n object
161
-	 * @param string $application
162
-	 * @param string|null $language
163
-	 * @return \OCP\IL10N
164
-	 * @since 6.0.0 - parameter $language was added in 8.0.0
165
-	 */
166
-	public static function getL10N($application, $language = null) {
167
-		return \OC::$server->getL10N($application, $language);
168
-	}
169
-
170
-	/**
171
-	 * add a css file
172
-	 * @param string $application
173
-	 * @param string $file
174
-	 * @since 4.0.0
175
-	 */
176
-	public static function addStyle($application, $file = null) {
177
-		\OC_Util::addStyle($application, $file);
178
-	}
179
-
180
-	/**
181
-	 * add a javascript file
182
-	 * @param string $application
183
-	 * @param string $file
184
-	 * @since 4.0.0
185
-	 */
186
-	public static function addScript($application, $file = null) {
187
-		\OC_Util::addScript($application, $file);
188
-	}
189
-
190
-	/**
191
-	 * Add a translation JS file
192
-	 * @param string $application application id
193
-	 * @param string $languageCode language code, defaults to the current locale
194
-	 * @since 8.0.0
195
-	 */
196
-	public static function addTranslations($application, $languageCode = null) {
197
-		\OC_Util::addTranslations($application, $languageCode);
198
-	}
199
-
200
-	/**
201
-	 * Add a custom element to the header
202
-	 * If $text is null then the element will be written as empty element.
203
-	 * So use "" to get a closing tag.
204
-	 * @param string $tag tag name of the element
205
-	 * @param array $attributes array of attributes for the element
206
-	 * @param string $text the text content for the element
207
-	 * @since 4.0.0
208
-	 */
209
-	public static function addHeader($tag, $attributes, $text = null) {
210
-		\OC_Util::addHeader($tag, $attributes, $text);
211
-	}
212
-
213
-	/**
214
-	 * Creates an absolute url to the given app and file.
215
-	 * @param string $app app
216
-	 * @param string $file file
217
-	 * @param array $args array with param=>value, will be appended to the returned url
218
-	 * 	The value of $args will be urlencoded
219
-	 * @return string the url
220
-	 * @since 4.0.0 - parameter $args was added in 4.5.0
221
-	 */
222
-	public static function linkToAbsolute($app, $file, $args = []) {
223
-		$urlGenerator = \OC::$server->getURLGenerator();
224
-		return $urlGenerator->getAbsoluteURL(
225
-			$urlGenerator->linkTo($app, $file, $args)
226
-		);
227
-	}
228
-
229
-	/**
230
-	 * Creates an absolute url for remote use.
231
-	 * @param string $service id
232
-	 * @return string the url
233
-	 * @since 4.0.0
234
-	 */
235
-	public static function linkToRemote($service) {
236
-		$urlGenerator = \OC::$server->getURLGenerator();
237
-		$remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service;
238
-		return $urlGenerator->getAbsoluteURL(
239
-			$remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '')
240
-		);
241
-	}
242
-
243
-	/**
244
-	 * Creates an absolute url for public use
245
-	 * @param string $service id
246
-	 * @return string the url
247
-	 * @since 4.5.0
248
-	 * @deprecated 15.0.0 - use OCP\IURLGenerator
249
-	 */
250
-	public static function linkToPublic($service) {
251
-		$urlGenerator = \OC::$server->getURLGenerator();
252
-		if ($service === 'files') {
253
-			return $urlGenerator->getAbsoluteURL('/s');
254
-		}
255
-		return $urlGenerator->getAbsoluteURL($urlGenerator->linkTo('', 'public.php').'?service='.$service);
256
-	}
257
-
258
-	/**
259
-	 * Returns the server host name without an eventual port number
260
-	 * @return string the server hostname
261
-	 * @since 5.0.0
262
-	 */
263
-	public static function getServerHostName() {
264
-		$host_name = \OC::$server->getRequest()->getServerHost();
265
-		// strip away port number (if existing)
266
-		$colon_pos = strpos($host_name, ':');
267
-		if ($colon_pos != false) {
268
-			$host_name = substr($host_name, 0, $colon_pos);
269
-		}
270
-		return $host_name;
271
-	}
272
-
273
-	/**
274
-	 * Returns the default email address
275
-	 * @param string $user_part the user part of the address
276
-	 * @return string the default email address
277
-	 *
278
-	 * Assembles a default email address (using the server hostname
279
-	 * and the given user part, and returns it
280
-	 * Example: when given lostpassword-noreply as $user_part param,
281
-	 *     and is currently accessed via http(s)://example.com/,
282
-	 *     it would return '[email protected]'
283
-	 *
284
-	 * If the configuration value 'mail_from_address' is set in
285
-	 * config.php, this value will override the $user_part that
286
-	 * is passed to this function
287
-	 * @since 5.0.0
288
-	 */
289
-	public static function getDefaultEmailAddress($user_part) {
290
-		$config = \OC::$server->getConfig();
291
-		$user_part = $config->getSystemValue('mail_from_address', $user_part);
292
-		$host_name = self::getServerHostName();
293
-		$host_name = $config->getSystemValue('mail_domain', $host_name);
294
-		$defaultEmailAddress = $user_part.'@'.$host_name;
295
-
296
-		$mailer = \OC::$server->getMailer();
297
-		if ($mailer->validateMailAddress($defaultEmailAddress)) {
298
-			return $defaultEmailAddress;
299
-		}
300
-
301
-		// in case we cannot build a valid email address from the hostname let's fallback to 'localhost.localdomain'
302
-		return $user_part.'@localhost.localdomain';
303
-	}
304
-
305
-	/**
306
-	 * Make a human file size (2048 to 2 kB)
307
-	 * @param int $bytes file size in bytes
308
-	 * @return string a human readable file size
309
-	 * @since 4.0.0
310
-	 */
311
-	public static function humanFileSize($bytes) {
312
-		return \OC_Helper::humanFileSize($bytes);
313
-	}
314
-
315
-	/**
316
-	 * Make a computer file size (2 kB to 2048)
317
-	 * @param string $str file size in a fancy format
318
-	 * @return float a file size in bytes
319
-	 *
320
-	 * Inspired by: https://www.php.net/manual/en/function.filesize.php#92418
321
-	 * @since 4.0.0
322
-	 */
323
-	public static function computerFileSize($str) {
324
-		return \OC_Helper::computerFileSize($str);
325
-	}
326
-
327
-	/**
328
-	 * connects a function to a hook
329
-	 *
330
-	 * @param string $signalClass class name of emitter
331
-	 * @param string $signalName name of signal
332
-	 * @param string|object $slotClass class name of slot
333
-	 * @param string $slotName name of slot
334
-	 * @return bool
335
-	 *
336
-	 * This function makes it very easy to connect to use hooks.
337
-	 *
338
-	 * TODO: write example
339
-	 * @since 4.0.0
340
-	 * @deprecated 21.0.0 use \OCP\EventDispatcher\IEventDispatcher::addListener
341
-	 */
342
-	public static function connectHook($signalClass, $signalName, $slotClass, $slotName) {
343
-		return \OC_Hook::connect($signalClass, $signalName, $slotClass, $slotName);
344
-	}
345
-
346
-	/**
347
-	 * Emits a signal. To get data from the slot use references!
348
-	 * @param string $signalclass class name of emitter
349
-	 * @param string $signalname name of signal
350
-	 * @param array $params default: array() array with additional data
351
-	 * @return bool true if slots exists or false if not
352
-	 *
353
-	 * TODO: write example
354
-	 * @since 4.0.0
355
-	 * @deprecated 21.0.0 use \OCP\EventDispatcher\IEventDispatcher::dispatchTypedEvent
356
-	 */
357
-	public static function emitHook($signalclass, $signalname, $params = []) {
358
-		return \OC_Hook::emit($signalclass, $signalname, $params);
359
-	}
360
-
361
-	/**
362
-	 * Cached encrypted CSRF token. Some static unit-tests of ownCloud compare
363
-	 * multiple OC_Template elements which invoke `callRegister`. If the value
364
-	 * would not be cached these unit-tests would fail.
365
-	 * @var string
366
-	 */
367
-	private static $token = '';
368
-
369
-	/**
370
-	 * Register an get/post call. This is important to prevent CSRF attacks
371
-	 * @since 4.5.0
372
-	 */
373
-	public static function callRegister() {
374
-		if (self::$token === '') {
375
-			self::$token = \OC::$server->getCsrfTokenManager()->getToken()->getEncryptedValue();
376
-		}
377
-		return self::$token;
378
-	}
379
-
380
-	/**
381
-	 * Used to sanitize HTML
382
-	 *
383
-	 * This function is used to sanitize HTML and should be applied on any
384
-	 * string or array of strings before displaying it on a web page.
385
-	 *
386
-	 * @param string|array $value
387
-	 * @return string|array an array of sanitized strings or a single sanitized string, depends on the input parameter.
388
-	 * @since 4.5.0
389
-	 */
390
-	public static function sanitizeHTML($value) {
391
-		return \OC_Util::sanitizeHTML($value);
392
-	}
393
-
394
-	/**
395
-	 * Public function to encode url parameters
396
-	 *
397
-	 * This function is used to encode path to file before output.
398
-	 * Encoding is done according to RFC 3986 with one exception:
399
-	 * Character '/' is preserved as is.
400
-	 *
401
-	 * @param string $component part of URI to encode
402
-	 * @return string
403
-	 * @since 6.0.0
404
-	 */
405
-	public static function encodePath($component) {
406
-		return \OC_Util::encodePath($component);
407
-	}
408
-
409
-	/**
410
-	 * Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
411
-	 *
412
-	 * @param array $input The array to work on
413
-	 * @param int $case Either MB_CASE_UPPER or MB_CASE_LOWER (default)
414
-	 * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
415
-	 * @return array
416
-	 * @since 4.5.0
417
-	 */
418
-	public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') {
419
-		return \OC_Helper::mb_array_change_key_case($input, $case, $encoding);
420
-	}
421
-
422
-	/**
423
-	 * performs a search in a nested array
424
-	 *
425
-	 * @param array $haystack the array to be searched
426
-	 * @param string $needle the search string
427
-	 * @param mixed $index optional, only search this key name
428
-	 * @return mixed the key of the matching field, otherwise false
429
-	 * @since 4.5.0
430
-	 * @deprecated 15.0.0
431
-	 */
432
-	public static function recursiveArraySearch($haystack, $needle, $index = null) {
433
-		return \OC_Helper::recursiveArraySearch($haystack, $needle, $index);
434
-	}
435
-
436
-	/**
437
-	 * calculates the maximum upload size respecting system settings, free space and user quota
438
-	 *
439
-	 * @param string $dir the current folder where the user currently operates
440
-	 * @param int $free the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly
441
-	 * @return int number of bytes representing
442
-	 * @since 5.0.0
443
-	 */
444
-	public static function maxUploadFilesize($dir, $free = null) {
445
-		return \OC_Helper::maxUploadFilesize($dir, $free);
446
-	}
447
-
448
-	/**
449
-	 * Calculate free space left within user quota
450
-	 * @param string $dir the current folder where the user currently operates
451
-	 * @return int number of bytes representing
452
-	 * @since 7.0.0
453
-	 */
454
-	public static function freeSpace($dir) {
455
-		return \OC_Helper::freeSpace($dir);
456
-	}
457
-
458
-	/**
459
-	 * Calculate PHP upload limit
460
-	 *
461
-	 * @return int number of bytes representing
462
-	 * @since 7.0.0
463
-	 */
464
-	public static function uploadLimit() {
465
-		return \OC_Helper::uploadLimit();
466
-	}
467
-
468
-	/**
469
-	 * Returns whether the given file name is valid
470
-	 * @param string $file file name to check
471
-	 * @return bool true if the file name is valid, false otherwise
472
-	 * @deprecated 8.1.0 use \OC\Files\View::verifyPath()
473
-	 * @since 7.0.0
474
-	 * @suppress PhanDeprecatedFunction
475
-	 */
476
-	public static function isValidFileName($file) {
477
-		return \OC_Util::isValidFileName($file);
478
-	}
479
-
480
-	/**
481
-	 * Compare two strings to provide a natural sort
482
-	 * @param string $a first string to compare
483
-	 * @param string $b second string to compare
484
-	 * @return int -1 if $b comes before $a, 1 if $a comes before $b
485
-	 * or 0 if the strings are identical
486
-	 * @since 7.0.0
487
-	 */
488
-	public static function naturalSortCompare($a, $b) {
489
-		return \OC\NaturalSort::getInstance()->compare($a, $b);
490
-	}
491
-
492
-	/**
493
-	 * check if a password is required for each public link
494
-	 * @return boolean
495
-	 * @since 7.0.0
496
-	 */
497
-	public static function isPublicLinkPasswordRequired() {
498
-		return \OC_Util::isPublicLinkPasswordRequired();
499
-	}
500
-
501
-	/**
502
-	 * check if share API enforces a default expire date
503
-	 * @return boolean
504
-	 * @since 8.0.0
505
-	 */
506
-	public static function isDefaultExpireDateEnforced() {
507
-		return \OC_Util::isDefaultExpireDateEnforced();
508
-	}
509
-
510
-	protected static $needUpgradeCache = null;
511
-
512
-	/**
513
-	 * Checks whether the current version needs upgrade.
514
-	 *
515
-	 * @return bool true if upgrade is needed, false otherwise
516
-	 * @since 7.0.0
517
-	 */
518
-	public static function needUpgrade() {
519
-		if (!isset(self::$needUpgradeCache)) {
520
-			self::$needUpgradeCache = \OC_Util::needUpgrade(\OC::$server->getSystemConfig());
521
-		}
522
-		return self::$needUpgradeCache;
523
-	}
62
+    /**
63
+     * @deprecated 14.0.0 use \OCP\ILogger::DEBUG
64
+     */
65
+    public const DEBUG = 0;
66
+    /**
67
+     * @deprecated 14.0.0 use \OCP\ILogger::INFO
68
+     */
69
+    public const INFO = 1;
70
+    /**
71
+     * @deprecated 14.0.0 use \OCP\ILogger::WARN
72
+     */
73
+    public const WARN = 2;
74
+    /**
75
+     * @deprecated 14.0.0 use \OCP\ILogger::ERROR
76
+     */
77
+    public const ERROR = 3;
78
+    /**
79
+     * @deprecated 14.0.0 use \OCP\ILogger::FATAL
80
+     */
81
+    public const FATAL = 4;
82
+
83
+    /** \OCP\Share\IManager */
84
+    private static $shareManager;
85
+
86
+    /**
87
+     * get the current installed version of Nextcloud
88
+     * @return array
89
+     * @since 4.0.0
90
+     */
91
+    public static function getVersion() {
92
+        return \OC_Util::getVersion();
93
+    }
94
+
95
+    /**
96
+     * @since 17.0.0
97
+     */
98
+    public static function hasExtendedSupport(): bool {
99
+        try {
100
+            /** @var \OCP\Support\Subscription\IRegistry */
101
+            $subscriptionRegistry = \OC::$server->query(\OCP\Support\Subscription\IRegistry::class);
102
+            return $subscriptionRegistry->delegateHasExtendedSupport();
103
+        } catch (AppFramework\QueryException $e) {
104
+        }
105
+        return \OC::$server->getConfig()->getSystemValueBool('extendedSupport', false);
106
+    }
107
+
108
+    /**
109
+     * Set current update channel
110
+     * @param string $channel
111
+     * @since 8.1.0
112
+     */
113
+    public static function setChannel($channel) {
114
+        \OC::$server->getConfig()->setSystemValue('updater.release.channel', $channel);
115
+    }
116
+
117
+    /**
118
+     * Get current update channel
119
+     * @return string
120
+     * @since 8.1.0
121
+     */
122
+    public static function getChannel() {
123
+        return \OC_Util::getChannel();
124
+    }
125
+
126
+    /**
127
+     * write a message in the log
128
+     * @param string $app
129
+     * @param string $message
130
+     * @param int $level
131
+     * @since 4.0.0
132
+     * @deprecated 13.0.0 use log of \OCP\ILogger
133
+     */
134
+    public static function writeLog($app, $message, $level) {
135
+        $context = ['app' => $app];
136
+        \OC::$server->getLogger()->log($level, $message, $context);
137
+    }
138
+
139
+    /**
140
+     * check if sharing is disabled for the current user
141
+     *
142
+     * @return boolean
143
+     * @since 7.0.0
144
+     * @deprecated 9.1.0 Use \OC::$server->getShareManager()->sharingDisabledForUser
145
+     */
146
+    public static function isSharingDisabledForUser() {
147
+        if (self::$shareManager === null) {
148
+            self::$shareManager = \OC::$server->getShareManager();
149
+        }
150
+
151
+        $user = \OC::$server->getUserSession()->getUser();
152
+        if ($user !== null) {
153
+            $user = $user->getUID();
154
+        }
155
+
156
+        return self::$shareManager->sharingDisabledForUser($user);
157
+    }
158
+
159
+    /**
160
+     * get l10n object
161
+     * @param string $application
162
+     * @param string|null $language
163
+     * @return \OCP\IL10N
164
+     * @since 6.0.0 - parameter $language was added in 8.0.0
165
+     */
166
+    public static function getL10N($application, $language = null) {
167
+        return \OC::$server->getL10N($application, $language);
168
+    }
169
+
170
+    /**
171
+     * add a css file
172
+     * @param string $application
173
+     * @param string $file
174
+     * @since 4.0.0
175
+     */
176
+    public static function addStyle($application, $file = null) {
177
+        \OC_Util::addStyle($application, $file);
178
+    }
179
+
180
+    /**
181
+     * add a javascript file
182
+     * @param string $application
183
+     * @param string $file
184
+     * @since 4.0.0
185
+     */
186
+    public static function addScript($application, $file = null) {
187
+        \OC_Util::addScript($application, $file);
188
+    }
189
+
190
+    /**
191
+     * Add a translation JS file
192
+     * @param string $application application id
193
+     * @param string $languageCode language code, defaults to the current locale
194
+     * @since 8.0.0
195
+     */
196
+    public static function addTranslations($application, $languageCode = null) {
197
+        \OC_Util::addTranslations($application, $languageCode);
198
+    }
199
+
200
+    /**
201
+     * Add a custom element to the header
202
+     * If $text is null then the element will be written as empty element.
203
+     * So use "" to get a closing tag.
204
+     * @param string $tag tag name of the element
205
+     * @param array $attributes array of attributes for the element
206
+     * @param string $text the text content for the element
207
+     * @since 4.0.0
208
+     */
209
+    public static function addHeader($tag, $attributes, $text = null) {
210
+        \OC_Util::addHeader($tag, $attributes, $text);
211
+    }
212
+
213
+    /**
214
+     * Creates an absolute url to the given app and file.
215
+     * @param string $app app
216
+     * @param string $file file
217
+     * @param array $args array with param=>value, will be appended to the returned url
218
+     * 	The value of $args will be urlencoded
219
+     * @return string the url
220
+     * @since 4.0.0 - parameter $args was added in 4.5.0
221
+     */
222
+    public static function linkToAbsolute($app, $file, $args = []) {
223
+        $urlGenerator = \OC::$server->getURLGenerator();
224
+        return $urlGenerator->getAbsoluteURL(
225
+            $urlGenerator->linkTo($app, $file, $args)
226
+        );
227
+    }
228
+
229
+    /**
230
+     * Creates an absolute url for remote use.
231
+     * @param string $service id
232
+     * @return string the url
233
+     * @since 4.0.0
234
+     */
235
+    public static function linkToRemote($service) {
236
+        $urlGenerator = \OC::$server->getURLGenerator();
237
+        $remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service;
238
+        return $urlGenerator->getAbsoluteURL(
239
+            $remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '')
240
+        );
241
+    }
242
+
243
+    /**
244
+     * Creates an absolute url for public use
245
+     * @param string $service id
246
+     * @return string the url
247
+     * @since 4.5.0
248
+     * @deprecated 15.0.0 - use OCP\IURLGenerator
249
+     */
250
+    public static function linkToPublic($service) {
251
+        $urlGenerator = \OC::$server->getURLGenerator();
252
+        if ($service === 'files') {
253
+            return $urlGenerator->getAbsoluteURL('/s');
254
+        }
255
+        return $urlGenerator->getAbsoluteURL($urlGenerator->linkTo('', 'public.php').'?service='.$service);
256
+    }
257
+
258
+    /**
259
+     * Returns the server host name without an eventual port number
260
+     * @return string the server hostname
261
+     * @since 5.0.0
262
+     */
263
+    public static function getServerHostName() {
264
+        $host_name = \OC::$server->getRequest()->getServerHost();
265
+        // strip away port number (if existing)
266
+        $colon_pos = strpos($host_name, ':');
267
+        if ($colon_pos != false) {
268
+            $host_name = substr($host_name, 0, $colon_pos);
269
+        }
270
+        return $host_name;
271
+    }
272
+
273
+    /**
274
+     * Returns the default email address
275
+     * @param string $user_part the user part of the address
276
+     * @return string the default email address
277
+     *
278
+     * Assembles a default email address (using the server hostname
279
+     * and the given user part, and returns it
280
+     * Example: when given lostpassword-noreply as $user_part param,
281
+     *     and is currently accessed via http(s)://example.com/,
282
+     *     it would return '[email protected]'
283
+     *
284
+     * If the configuration value 'mail_from_address' is set in
285
+     * config.php, this value will override the $user_part that
286
+     * is passed to this function
287
+     * @since 5.0.0
288
+     */
289
+    public static function getDefaultEmailAddress($user_part) {
290
+        $config = \OC::$server->getConfig();
291
+        $user_part = $config->getSystemValue('mail_from_address', $user_part);
292
+        $host_name = self::getServerHostName();
293
+        $host_name = $config->getSystemValue('mail_domain', $host_name);
294
+        $defaultEmailAddress = $user_part.'@'.$host_name;
295
+
296
+        $mailer = \OC::$server->getMailer();
297
+        if ($mailer->validateMailAddress($defaultEmailAddress)) {
298
+            return $defaultEmailAddress;
299
+        }
300
+
301
+        // in case we cannot build a valid email address from the hostname let's fallback to 'localhost.localdomain'
302
+        return $user_part.'@localhost.localdomain';
303
+    }
304
+
305
+    /**
306
+     * Make a human file size (2048 to 2 kB)
307
+     * @param int $bytes file size in bytes
308
+     * @return string a human readable file size
309
+     * @since 4.0.0
310
+     */
311
+    public static function humanFileSize($bytes) {
312
+        return \OC_Helper::humanFileSize($bytes);
313
+    }
314
+
315
+    /**
316
+     * Make a computer file size (2 kB to 2048)
317
+     * @param string $str file size in a fancy format
318
+     * @return float a file size in bytes
319
+     *
320
+     * Inspired by: https://www.php.net/manual/en/function.filesize.php#92418
321
+     * @since 4.0.0
322
+     */
323
+    public static function computerFileSize($str) {
324
+        return \OC_Helper::computerFileSize($str);
325
+    }
326
+
327
+    /**
328
+     * connects a function to a hook
329
+     *
330
+     * @param string $signalClass class name of emitter
331
+     * @param string $signalName name of signal
332
+     * @param string|object $slotClass class name of slot
333
+     * @param string $slotName name of slot
334
+     * @return bool
335
+     *
336
+     * This function makes it very easy to connect to use hooks.
337
+     *
338
+     * TODO: write example
339
+     * @since 4.0.0
340
+     * @deprecated 21.0.0 use \OCP\EventDispatcher\IEventDispatcher::addListener
341
+     */
342
+    public static function connectHook($signalClass, $signalName, $slotClass, $slotName) {
343
+        return \OC_Hook::connect($signalClass, $signalName, $slotClass, $slotName);
344
+    }
345
+
346
+    /**
347
+     * Emits a signal. To get data from the slot use references!
348
+     * @param string $signalclass class name of emitter
349
+     * @param string $signalname name of signal
350
+     * @param array $params default: array() array with additional data
351
+     * @return bool true if slots exists or false if not
352
+     *
353
+     * TODO: write example
354
+     * @since 4.0.0
355
+     * @deprecated 21.0.0 use \OCP\EventDispatcher\IEventDispatcher::dispatchTypedEvent
356
+     */
357
+    public static function emitHook($signalclass, $signalname, $params = []) {
358
+        return \OC_Hook::emit($signalclass, $signalname, $params);
359
+    }
360
+
361
+    /**
362
+     * Cached encrypted CSRF token. Some static unit-tests of ownCloud compare
363
+     * multiple OC_Template elements which invoke `callRegister`. If the value
364
+     * would not be cached these unit-tests would fail.
365
+     * @var string
366
+     */
367
+    private static $token = '';
368
+
369
+    /**
370
+     * Register an get/post call. This is important to prevent CSRF attacks
371
+     * @since 4.5.0
372
+     */
373
+    public static function callRegister() {
374
+        if (self::$token === '') {
375
+            self::$token = \OC::$server->getCsrfTokenManager()->getToken()->getEncryptedValue();
376
+        }
377
+        return self::$token;
378
+    }
379
+
380
+    /**
381
+     * Used to sanitize HTML
382
+     *
383
+     * This function is used to sanitize HTML and should be applied on any
384
+     * string or array of strings before displaying it on a web page.
385
+     *
386
+     * @param string|array $value
387
+     * @return string|array an array of sanitized strings or a single sanitized string, depends on the input parameter.
388
+     * @since 4.5.0
389
+     */
390
+    public static function sanitizeHTML($value) {
391
+        return \OC_Util::sanitizeHTML($value);
392
+    }
393
+
394
+    /**
395
+     * Public function to encode url parameters
396
+     *
397
+     * This function is used to encode path to file before output.
398
+     * Encoding is done according to RFC 3986 with one exception:
399
+     * Character '/' is preserved as is.
400
+     *
401
+     * @param string $component part of URI to encode
402
+     * @return string
403
+     * @since 6.0.0
404
+     */
405
+    public static function encodePath($component) {
406
+        return \OC_Util::encodePath($component);
407
+    }
408
+
409
+    /**
410
+     * Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
411
+     *
412
+     * @param array $input The array to work on
413
+     * @param int $case Either MB_CASE_UPPER or MB_CASE_LOWER (default)
414
+     * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
415
+     * @return array
416
+     * @since 4.5.0
417
+     */
418
+    public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') {
419
+        return \OC_Helper::mb_array_change_key_case($input, $case, $encoding);
420
+    }
421
+
422
+    /**
423
+     * performs a search in a nested array
424
+     *
425
+     * @param array $haystack the array to be searched
426
+     * @param string $needle the search string
427
+     * @param mixed $index optional, only search this key name
428
+     * @return mixed the key of the matching field, otherwise false
429
+     * @since 4.5.0
430
+     * @deprecated 15.0.0
431
+     */
432
+    public static function recursiveArraySearch($haystack, $needle, $index = null) {
433
+        return \OC_Helper::recursiveArraySearch($haystack, $needle, $index);
434
+    }
435
+
436
+    /**
437
+     * calculates the maximum upload size respecting system settings, free space and user quota
438
+     *
439
+     * @param string $dir the current folder where the user currently operates
440
+     * @param int $free the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly
441
+     * @return int number of bytes representing
442
+     * @since 5.0.0
443
+     */
444
+    public static function maxUploadFilesize($dir, $free = null) {
445
+        return \OC_Helper::maxUploadFilesize($dir, $free);
446
+    }
447
+
448
+    /**
449
+     * Calculate free space left within user quota
450
+     * @param string $dir the current folder where the user currently operates
451
+     * @return int number of bytes representing
452
+     * @since 7.0.0
453
+     */
454
+    public static function freeSpace($dir) {
455
+        return \OC_Helper::freeSpace($dir);
456
+    }
457
+
458
+    /**
459
+     * Calculate PHP upload limit
460
+     *
461
+     * @return int number of bytes representing
462
+     * @since 7.0.0
463
+     */
464
+    public static function uploadLimit() {
465
+        return \OC_Helper::uploadLimit();
466
+    }
467
+
468
+    /**
469
+     * Returns whether the given file name is valid
470
+     * @param string $file file name to check
471
+     * @return bool true if the file name is valid, false otherwise
472
+     * @deprecated 8.1.0 use \OC\Files\View::verifyPath()
473
+     * @since 7.0.0
474
+     * @suppress PhanDeprecatedFunction
475
+     */
476
+    public static function isValidFileName($file) {
477
+        return \OC_Util::isValidFileName($file);
478
+    }
479
+
480
+    /**
481
+     * Compare two strings to provide a natural sort
482
+     * @param string $a first string to compare
483
+     * @param string $b second string to compare
484
+     * @return int -1 if $b comes before $a, 1 if $a comes before $b
485
+     * or 0 if the strings are identical
486
+     * @since 7.0.0
487
+     */
488
+    public static function naturalSortCompare($a, $b) {
489
+        return \OC\NaturalSort::getInstance()->compare($a, $b);
490
+    }
491
+
492
+    /**
493
+     * check if a password is required for each public link
494
+     * @return boolean
495
+     * @since 7.0.0
496
+     */
497
+    public static function isPublicLinkPasswordRequired() {
498
+        return \OC_Util::isPublicLinkPasswordRequired();
499
+    }
500
+
501
+    /**
502
+     * check if share API enforces a default expire date
503
+     * @return boolean
504
+     * @since 8.0.0
505
+     */
506
+    public static function isDefaultExpireDateEnforced() {
507
+        return \OC_Util::isDefaultExpireDateEnforced();
508
+    }
509
+
510
+    protected static $needUpgradeCache = null;
511
+
512
+    /**
513
+     * Checks whether the current version needs upgrade.
514
+     *
515
+     * @return bool true if upgrade is needed, false otherwise
516
+     * @since 7.0.0
517
+     */
518
+    public static function needUpgrade() {
519
+        if (!isset(self::$needUpgradeCache)) {
520
+            self::$needUpgradeCache = \OC_Util::needUpgrade(\OC::$server->getSystemConfig());
521
+        }
522
+        return self::$needUpgradeCache;
523
+    }
524 524
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/Controller.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 		// default responders
80 80
 		$this->responders = [
81
-			'json' => function ($data) {
81
+			'json' => function($data) {
82 82
 				if ($data instanceof DataResponse) {
83 83
 					$response = new JSONResponse(
84 84
 						$data->getData(),
@@ -153,6 +153,6 @@  discard block
 block discarded – undo
153 153
 			return $responder($response);
154 154
 		}
155 155
 		throw new \DomainException('No responder registered for format '.
156
-			$format . '!');
156
+			$format.'!');
157 157
 	}
158 158
 }
Please login to merge, or discard this patch.
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -45,122 +45,122 @@
 block discarded – undo
45 45
  */
46 46
 abstract class Controller {
47 47
 
48
-	/**
49
-	 * app name
50
-	 * @var string
51
-	 * @since 7.0.0
52
-	 */
53
-	protected $appName;
54
-
55
-	/**
56
-	 * current request
57
-	 * @var \OCP\IRequest
58
-	 * @since 6.0.0
59
-	 */
60
-	protected $request;
61
-
62
-	/**
63
-	 * @var array
64
-	 * @since 7.0.0
65
-	 */
66
-	private $responders;
67
-
68
-	/**
69
-	 * constructor of the controller
70
-	 * @param string $appName the name of the app
71
-	 * @param IRequest $request an instance of the request
72
-	 * @since 6.0.0 - parameter $appName was added in 7.0.0 - parameter $app was removed in 7.0.0
73
-	 */
74
-	public function __construct($appName,
75
-								IRequest $request) {
76
-		$this->appName = $appName;
77
-		$this->request = $request;
78
-
79
-		// default responders
80
-		$this->responders = [
81
-			'json' => function ($data) {
82
-				if ($data instanceof DataResponse) {
83
-					$response = new JSONResponse(
84
-						$data->getData(),
85
-						$data->getStatus()
86
-					);
87
-					$dataHeaders = $data->getHeaders();
88
-					$headers = $response->getHeaders();
89
-					// do not overwrite Content-Type if it already exists
90
-					if (isset($dataHeaders['Content-Type'])) {
91
-						unset($headers['Content-Type']);
92
-					}
93
-					$response->setHeaders(array_merge($dataHeaders, $headers));
94
-
95
-					if ($data->getETag() !== null) {
96
-						$response->setETag($data->getETag());
97
-					}
98
-					if ($data->getLastModified() !== null) {
99
-						$response->setLastModified($data->getLastModified());
100
-					}
101
-
102
-					return $response;
103
-				}
104
-				return new JSONResponse($data);
105
-			}
106
-		];
107
-	}
108
-
109
-
110
-	/**
111
-	 * Parses an HTTP accept header and returns the supported responder type
112
-	 * @param string $acceptHeader
113
-	 * @param string $default
114
-	 * @return string the responder type
115
-	 * @since 7.0.0
116
-	 * @since 9.1.0 Added default parameter
117
-	 */
118
-	public function getResponderByHTTPHeader($acceptHeader, $default = 'json') {
119
-		$headers = explode(',', $acceptHeader);
120
-
121
-		// return the first matching responder
122
-		foreach ($headers as $header) {
123
-			$header = strtolower(trim($header));
124
-
125
-			$responder = str_replace('application/', '', $header);
126
-
127
-			if (array_key_exists($responder, $this->responders)) {
128
-				return $responder;
129
-			}
130
-		}
131
-
132
-		// no matching header return default
133
-		return $default;
134
-	}
135
-
136
-
137
-	/**
138
-	 * Registers a formatter for a type
139
-	 * @param string $format
140
-	 * @param \Closure $responder
141
-	 * @since 7.0.0
142
-	 */
143
-	protected function registerResponder($format, \Closure $responder) {
144
-		$this->responders[$format] = $responder;
145
-	}
146
-
147
-
148
-	/**
149
-	 * Serializes and formats a response
150
-	 * @param mixed $response the value that was returned from a controller and
151
-	 * is not a Response instance
152
-	 * @param string $format the format for which a formatter has been registered
153
-	 * @throws \DomainException if format does not match a registered formatter
154
-	 * @return Response
155
-	 * @since 7.0.0
156
-	 */
157
-	public function buildResponse($response, $format = 'json') {
158
-		if (array_key_exists($format, $this->responders)) {
159
-			$responder = $this->responders[$format];
160
-
161
-			return $responder($response);
162
-		}
163
-		throw new \DomainException('No responder registered for format '.
164
-			$format . '!');
165
-	}
48
+    /**
49
+     * app name
50
+     * @var string
51
+     * @since 7.0.0
52
+     */
53
+    protected $appName;
54
+
55
+    /**
56
+     * current request
57
+     * @var \OCP\IRequest
58
+     * @since 6.0.0
59
+     */
60
+    protected $request;
61
+
62
+    /**
63
+     * @var array
64
+     * @since 7.0.0
65
+     */
66
+    private $responders;
67
+
68
+    /**
69
+     * constructor of the controller
70
+     * @param string $appName the name of the app
71
+     * @param IRequest $request an instance of the request
72
+     * @since 6.0.0 - parameter $appName was added in 7.0.0 - parameter $app was removed in 7.0.0
73
+     */
74
+    public function __construct($appName,
75
+                                IRequest $request) {
76
+        $this->appName = $appName;
77
+        $this->request = $request;
78
+
79
+        // default responders
80
+        $this->responders = [
81
+            'json' => function ($data) {
82
+                if ($data instanceof DataResponse) {
83
+                    $response = new JSONResponse(
84
+                        $data->getData(),
85
+                        $data->getStatus()
86
+                    );
87
+                    $dataHeaders = $data->getHeaders();
88
+                    $headers = $response->getHeaders();
89
+                    // do not overwrite Content-Type if it already exists
90
+                    if (isset($dataHeaders['Content-Type'])) {
91
+                        unset($headers['Content-Type']);
92
+                    }
93
+                    $response->setHeaders(array_merge($dataHeaders, $headers));
94
+
95
+                    if ($data->getETag() !== null) {
96
+                        $response->setETag($data->getETag());
97
+                    }
98
+                    if ($data->getLastModified() !== null) {
99
+                        $response->setLastModified($data->getLastModified());
100
+                    }
101
+
102
+                    return $response;
103
+                }
104
+                return new JSONResponse($data);
105
+            }
106
+        ];
107
+    }
108
+
109
+
110
+    /**
111
+     * Parses an HTTP accept header and returns the supported responder type
112
+     * @param string $acceptHeader
113
+     * @param string $default
114
+     * @return string the responder type
115
+     * @since 7.0.0
116
+     * @since 9.1.0 Added default parameter
117
+     */
118
+    public function getResponderByHTTPHeader($acceptHeader, $default = 'json') {
119
+        $headers = explode(',', $acceptHeader);
120
+
121
+        // return the first matching responder
122
+        foreach ($headers as $header) {
123
+            $header = strtolower(trim($header));
124
+
125
+            $responder = str_replace('application/', '', $header);
126
+
127
+            if (array_key_exists($responder, $this->responders)) {
128
+                return $responder;
129
+            }
130
+        }
131
+
132
+        // no matching header return default
133
+        return $default;
134
+    }
135
+
136
+
137
+    /**
138
+     * Registers a formatter for a type
139
+     * @param string $format
140
+     * @param \Closure $responder
141
+     * @since 7.0.0
142
+     */
143
+    protected function registerResponder($format, \Closure $responder) {
144
+        $this->responders[$format] = $responder;
145
+    }
146
+
147
+
148
+    /**
149
+     * Serializes and formats a response
150
+     * @param mixed $response the value that was returned from a controller and
151
+     * is not a Response instance
152
+     * @param string $format the format for which a formatter has been registered
153
+     * @throws \DomainException if format does not match a registered formatter
154
+     * @return Response
155
+     * @since 7.0.0
156
+     */
157
+    public function buildResponse($response, $format = 'json') {
158
+        if (array_key_exists($format, $this->responders)) {
159
+            $responder = $this->responders[$format];
160
+
161
+            return $responder($response);
162
+        }
163
+        throw new \DomainException('No responder registered for format '.
164
+            $format . '!');
165
+    }
166 166
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/Middleware.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -42,67 +42,67 @@
 block discarded – undo
42 42
 abstract class Middleware {
43 43
 
44 44
 
45
-	/**
46
-	 * This is being run in normal order before the controller is being
47
-	 * called which allows several modifications and checks
48
-	 *
49
-	 * @param Controller $controller the controller that is being called
50
-	 * @param string $methodName the name of the method that will be called on
51
-	 *                           the controller
52
-	 * @since 6.0.0
53
-	 */
54
-	public function beforeController($controller, $methodName) {
55
-	}
45
+    /**
46
+     * This is being run in normal order before the controller is being
47
+     * called which allows several modifications and checks
48
+     *
49
+     * @param Controller $controller the controller that is being called
50
+     * @param string $methodName the name of the method that will be called on
51
+     *                           the controller
52
+     * @since 6.0.0
53
+     */
54
+    public function beforeController($controller, $methodName) {
55
+    }
56 56
 
57 57
 
58
-	/**
59
-	 * This is being run when either the beforeController method or the
60
-	 * controller method itself is throwing an exception. The middleware is
61
-	 * asked in reverse order to handle the exception and to return a response.
62
-	 * If the response is null, it is assumed that the exception could not be
63
-	 * handled and the error will be thrown again
64
-	 *
65
-	 * @param Controller $controller the controller that is being called
66
-	 * @param string $methodName the name of the method that will be called on
67
-	 *                           the controller
68
-	 * @param \Exception $exception the thrown exception
69
-	 * @throws \Exception the passed in exception if it can't handle it
70
-	 * @return Response a Response object in case that the exception was handled
71
-	 * @since 6.0.0
72
-	 */
73
-	public function afterException($controller, $methodName, \Exception $exception) {
74
-		throw $exception;
75
-	}
58
+    /**
59
+     * This is being run when either the beforeController method or the
60
+     * controller method itself is throwing an exception. The middleware is
61
+     * asked in reverse order to handle the exception and to return a response.
62
+     * If the response is null, it is assumed that the exception could not be
63
+     * handled and the error will be thrown again
64
+     *
65
+     * @param Controller $controller the controller that is being called
66
+     * @param string $methodName the name of the method that will be called on
67
+     *                           the controller
68
+     * @param \Exception $exception the thrown exception
69
+     * @throws \Exception the passed in exception if it can't handle it
70
+     * @return Response a Response object in case that the exception was handled
71
+     * @since 6.0.0
72
+     */
73
+    public function afterException($controller, $methodName, \Exception $exception) {
74
+        throw $exception;
75
+    }
76 76
 
77 77
 
78
-	/**
79
-	 * This is being run after a successful controllermethod call and allows
80
-	 * the manipulation of a Response object. The middleware is run in reverse order
81
-	 *
82
-	 * @param Controller $controller the controller that is being called
83
-	 * @param string $methodName the name of the method that will be called on
84
-	 *                           the controller
85
-	 * @param Response $response the generated response from the controller
86
-	 * @return Response a Response object
87
-	 * @since 6.0.0
88
-	 */
89
-	public function afterController($controller, $methodName, Response $response) {
90
-		return $response;
91
-	}
78
+    /**
79
+     * This is being run after a successful controllermethod call and allows
80
+     * the manipulation of a Response object. The middleware is run in reverse order
81
+     *
82
+     * @param Controller $controller the controller that is being called
83
+     * @param string $methodName the name of the method that will be called on
84
+     *                           the controller
85
+     * @param Response $response the generated response from the controller
86
+     * @return Response a Response object
87
+     * @since 6.0.0
88
+     */
89
+    public function afterController($controller, $methodName, Response $response) {
90
+        return $response;
91
+    }
92 92
 
93 93
 
94
-	/**
95
-	 * This is being run after the response object has been rendered and
96
-	 * allows the manipulation of the output. The middleware is run in reverse order
97
-	 *
98
-	 * @param Controller $controller the controller that is being called
99
-	 * @param string $methodName the name of the method that will be called on
100
-	 *                           the controller
101
-	 * @param string $output the generated output from a response
102
-	 * @return string the output that should be printed
103
-	 * @since 6.0.0
104
-	 */
105
-	public function beforeOutput($controller, $methodName, $output) {
106
-		return $output;
107
-	}
94
+    /**
95
+     * This is being run after the response object has been rendered and
96
+     * allows the manipulation of the output. The middleware is run in reverse order
97
+     *
98
+     * @param Controller $controller the controller that is being called
99
+     * @param string $methodName the name of the method that will be called on
100
+     *                           the controller
101
+     * @param string $output the generated output from a response
102
+     * @return string the output that should be printed
103
+     * @since 6.0.0
104
+     */
105
+    public function beforeOutput($controller, $methodName, $output) {
106
+        return $output;
107
+    }
108 108
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/OCS/OCSNotFoundException.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@
 block discarded – undo
32 32
  * @since 9.1.0
33 33
  */
34 34
 class OCSNotFoundException extends OCSException {
35
-	/**
36
-	 * OCSNotFoundException constructor.
37
-	 *
38
-	 * @param string $message
39
-	 * @param Exception|null $previous
40
-	 * @since 9.1.0
41
-	 */
42
-	public function __construct($message = '', Exception $previous = null) {
43
-		parent::__construct($message, Http::STATUS_NOT_FOUND, $previous);
44
-	}
35
+    /**
36
+     * OCSNotFoundException constructor.
37
+     *
38
+     * @param string $message
39
+     * @param Exception|null $previous
40
+     * @since 9.1.0
41
+     */
42
+    public function __construct($message = '', Exception $previous = null) {
43
+        parent::__construct($message, Http::STATUS_NOT_FOUND, $previous);
44
+    }
45 45
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/OCS/OCSForbiddenException.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@
 block discarded – undo
32 32
  * @since 9.1.0
33 33
  */
34 34
 class OCSForbiddenException extends OCSException {
35
-	/**
36
-	 * OCSForbiddenException constructor.
37
-	 *
38
-	 * @param string $message
39
-	 * @param Exception|null $previous
40
-	 * @since 9.1.0
41
-	 */
42
-	public function __construct($message = '', Exception $previous = null) {
43
-		parent::__construct($message, Http::STATUS_FORBIDDEN, $previous);
44
-	}
35
+    /**
36
+     * OCSForbiddenException constructor.
37
+     *
38
+     * @param string $message
39
+     * @param Exception|null $previous
40
+     * @since 9.1.0
41
+     */
42
+    public function __construct($message = '', Exception $previous = null) {
43
+        parent::__construct($message, Http::STATUS_FORBIDDEN, $previous);
44
+    }
45 45
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/OCS/OCSBadRequestException.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@
 block discarded – undo
32 32
  * @since 9.1.0
33 33
  */
34 34
 class OCSBadRequestException extends OCSException {
35
-	/**
36
-	 * OCSBadRequestException constructor.
37
-	 *
38
-	 * @param string $message
39
-	 * @param Exception|null $previous
40
-	 * @since 9.1.0
41
-	 */
42
-	public function __construct($message = '', Exception $previous = null) {
43
-		parent::__construct($message, Http::STATUS_BAD_REQUEST, $previous);
44
-	}
35
+    /**
36
+     * OCSBadRequestException constructor.
37
+     *
38
+     * @param string $message
39
+     * @param Exception|null $previous
40
+     * @since 9.1.0
41
+     */
42
+    public function __construct($message = '', Exception $previous = null) {
43
+        parent::__construct($message, Http::STATUS_BAD_REQUEST, $previous);
44
+    }
45 45
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/Http/FileDisplayResponse.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		$this->file = $file;
52 52
 		$this->setStatus($statusCode);
53 53
 		$this->setHeaders(array_merge($this->getHeaders(), $headers));
54
-		$this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"');
54
+		$this->addHeader('Content-Disposition', 'inline; filename="'.rawurldecode($file->getName()).'"');
55 55
 
56 56
 		$this->setETag($file->getEtag());
57 57
 		$lastModified = new \DateTime();
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	public function callback(IOutput $output) {
67 67
 		if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) {
68
-			$output->setHeader('Content-Length: ' . $this->file->getSize());
68
+			$output->setHeader('Content-Length: '.$this->file->getSize());
69 69
 			$output->setOutput($this->file->getContent());
70 70
 		}
71 71
 	}
Please login to merge, or discard this patch.
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -32,40 +32,40 @@
 block discarded – undo
32 32
  */
33 33
 class FileDisplayResponse extends Response implements ICallbackResponse {
34 34
 
35
-	/** @var \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile */
36
-	private $file;
35
+    /** @var \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile */
36
+    private $file;
37 37
 
38
-	/**
39
-	 * FileDisplayResponse constructor.
40
-	 *
41
-	 * @param \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile $file
42
-	 * @param int $statusCode
43
-	 * @param array $headers
44
-	 * @since 11.0.0
45
-	 */
46
-	public function __construct($file, $statusCode = Http::STATUS_OK,
47
-								$headers = []) {
48
-		parent::__construct();
38
+    /**
39
+     * FileDisplayResponse constructor.
40
+     *
41
+     * @param \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile $file
42
+     * @param int $statusCode
43
+     * @param array $headers
44
+     * @since 11.0.0
45
+     */
46
+    public function __construct($file, $statusCode = Http::STATUS_OK,
47
+                                $headers = []) {
48
+        parent::__construct();
49 49
 
50
-		$this->file = $file;
51
-		$this->setStatus($statusCode);
52
-		$this->setHeaders(array_merge($this->getHeaders(), $headers));
53
-		$this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"');
50
+        $this->file = $file;
51
+        $this->setStatus($statusCode);
52
+        $this->setHeaders(array_merge($this->getHeaders(), $headers));
53
+        $this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"');
54 54
 
55
-		$this->setETag($file->getEtag());
56
-		$lastModified = new \DateTime();
57
-		$lastModified->setTimestamp($file->getMTime());
58
-		$this->setLastModified($lastModified);
59
-	}
55
+        $this->setETag($file->getEtag());
56
+        $lastModified = new \DateTime();
57
+        $lastModified->setTimestamp($file->getMTime());
58
+        $this->setLastModified($lastModified);
59
+    }
60 60
 
61
-	/**
62
-	 * @param IOutput $output
63
-	 * @since 11.0.0
64
-	 */
65
-	public function callback(IOutput $output) {
66
-		if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) {
67
-			$output->setHeader('Content-Length: ' . $this->file->getSize());
68
-			$output->setOutput($this->file->getContent());
69
-		}
70
-	}
61
+    /**
62
+     * @param IOutput $output
63
+     * @since 11.0.0
64
+     */
65
+    public function callback(IOutput $output) {
66
+        if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) {
67
+            $output->setHeader('Content-Length: ' . $this->file->getSize());
68
+            $output->setOutput($this->file->getContent());
69
+        }
70
+    }
71 71
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/Http/JSONResponse.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
 	public function render() {
69 69
 		$response = json_encode($this->data, JSON_HEX_TAG);
70 70
 		if ($response === false) {
71
-			throw new \Exception(sprintf('Could not json_encode due to invalid ' .
71
+			throw new \Exception(sprintf('Could not json_encode due to invalid '.
72 72
 				'non UTF-8 characters in the array: %s', var_export($this->data, true)));
73 73
 		}
74 74
 
Please login to merge, or discard this patch.
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -41,64 +41,64 @@
 block discarded – undo
41 41
  */
42 42
 class JSONResponse extends Response {
43 43
 
44
-	/**
45
-	 * response data
46
-	 * @var array|object
47
-	 */
48
-	protected $data;
44
+    /**
45
+     * response data
46
+     * @var array|object
47
+     */
48
+    protected $data;
49 49
 
50 50
 
51
-	/**
52
-	 * constructor of JSONResponse
53
-	 * @param array|object $data the object or array that should be transformed
54
-	 * @param int $statusCode the Http status code, defaults to 200
55
-	 * @since 6.0.0
56
-	 */
57
-	public function __construct($data = [], $statusCode = Http::STATUS_OK) {
58
-		parent::__construct();
51
+    /**
52
+     * constructor of JSONResponse
53
+     * @param array|object $data the object or array that should be transformed
54
+     * @param int $statusCode the Http status code, defaults to 200
55
+     * @since 6.0.0
56
+     */
57
+    public function __construct($data = [], $statusCode = Http::STATUS_OK) {
58
+        parent::__construct();
59 59
 
60
-		$this->data = $data;
61
-		$this->setStatus($statusCode);
62
-		$this->addHeader('Content-Type', 'application/json; charset=utf-8');
63
-	}
60
+        $this->data = $data;
61
+        $this->setStatus($statusCode);
62
+        $this->addHeader('Content-Type', 'application/json; charset=utf-8');
63
+    }
64 64
 
65 65
 
66
-	/**
67
-	 * Returns the rendered json
68
-	 * @return string the rendered json
69
-	 * @since 6.0.0
70
-	 * @throws \Exception If data could not get encoded
71
-	 */
72
-	public function render() {
73
-		$response = json_encode($this->data, JSON_HEX_TAG);
74
-		if ($response === false) {
75
-			throw new \Exception(sprintf('Could not json_encode due to invalid ' .
76
-				'non UTF-8 characters in the array: %s', var_export($this->data, true)));
77
-		}
66
+    /**
67
+     * Returns the rendered json
68
+     * @return string the rendered json
69
+     * @since 6.0.0
70
+     * @throws \Exception If data could not get encoded
71
+     */
72
+    public function render() {
73
+        $response = json_encode($this->data, JSON_HEX_TAG);
74
+        if ($response === false) {
75
+            throw new \Exception(sprintf('Could not json_encode due to invalid ' .
76
+                'non UTF-8 characters in the array: %s', var_export($this->data, true)));
77
+        }
78 78
 
79
-		return $response;
80
-	}
79
+        return $response;
80
+    }
81 81
 
82
-	/**
83
-	 * Sets values in the data json array
84
-	 * @param array|object $data an array or object which will be transformed
85
-	 *                             to JSON
86
-	 * @return JSONResponse Reference to this object
87
-	 * @since 6.0.0 - return value was added in 7.0.0
88
-	 */
89
-	public function setData($data) {
90
-		$this->data = $data;
82
+    /**
83
+     * Sets values in the data json array
84
+     * @param array|object $data an array or object which will be transformed
85
+     *                             to JSON
86
+     * @return JSONResponse Reference to this object
87
+     * @since 6.0.0 - return value was added in 7.0.0
88
+     */
89
+    public function setData($data) {
90
+        $this->data = $data;
91 91
 
92
-		return $this;
93
-	}
92
+        return $this;
93
+    }
94 94
 
95 95
 
96
-	/**
97
-	 * Used to get the set parameters
98
-	 * @return array the data
99
-	 * @since 6.0.0
100
-	 */
101
-	public function getData() {
102
-		return $this->data;
103
-	}
96
+    /**
97
+     * Used to get the set parameters
98
+     * @return array the data
99
+     * @since 6.0.0
100
+     */
101
+    public function getData() {
102
+        return $this->data;
103
+    }
104 104
 }
Please login to merge, or discard this patch.
lib/private/Archive/ZIP.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 			$result = $this->zip->addFromString($path, $source);
73 73
 		}
74 74
 		if ($result) {
75
-			$this->zip->close();//close and reopen to save the zip
75
+			$this->zip->close(); //close and reopen to save the zip
76 76
 			$this->zip->open($this->path);
77 77
 		}
78 78
 		return $result;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	public function getFiles() {
131 131
 		$fileCount = $this->zip->numFiles;
132 132
 		$files = [];
133
-		for ($i = 0;$i < $fileCount;$i++) {
133
+		for ($i = 0; $i < $fileCount; $i++) {
134 134
 			$files[] = $this->zip->getNameIndex($i);
135 135
 		}
136 136
 		return $files;
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 				$this->extractFile($path, $tmpFile);
205 205
 			}
206 206
 			$handle = fopen($tmpFile, $mode);
207
-			return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) {
207
+			return CallbackWrapper::wrap($handle, null, null, function() use ($path, $tmpFile) {
208 208
 				$this->writeBack($tmpFile, $path);
209 209
 			});
210 210
 		}
Please login to merge, or discard this patch.
Indentation   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -36,199 +36,199 @@
 block discarded – undo
36 36
 use OCP\ILogger;
37 37
 
38 38
 class ZIP extends Archive {
39
-	/**
40
-	 * @var \ZipArchive zip
41
-	 */
42
-	private $zip = null;
43
-	private $path;
39
+    /**
40
+     * @var \ZipArchive zip
41
+     */
42
+    private $zip = null;
43
+    private $path;
44 44
 
45
-	/**
46
-	 * @param string $source
47
-	 */
48
-	public function __construct($source) {
49
-		$this->path = $source;
50
-		$this->zip = new \ZipArchive();
51
-		if ($this->zip->open($source, \ZipArchive::CREATE)) {
52
-		} else {
53
-			\OCP\Util::writeLog('files_archive', 'Error while opening archive '.$source, ILogger::WARN);
54
-		}
55
-	}
56
-	/**
57
-	 * add an empty folder to the archive
58
-	 * @param string $path
59
-	 * @return bool
60
-	 */
61
-	public function addFolder($path) {
62
-		return $this->zip->addEmptyDir($path);
63
-	}
64
-	/**
65
-	 * add a file to the archive
66
-	 * @param string $path
67
-	 * @param string $source either a local file or string data
68
-	 * @return bool
69
-	 */
70
-	public function addFile($path, $source = '') {
71
-		if ($source and $source[0] == '/' and file_exists($source)) {
72
-			$result = $this->zip->addFile($source, $path);
73
-		} else {
74
-			$result = $this->zip->addFromString($path, $source);
75
-		}
76
-		if ($result) {
77
-			$this->zip->close();//close and reopen to save the zip
78
-			$this->zip->open($this->path);
79
-		}
80
-		return $result;
81
-	}
82
-	/**
83
-	 * rename a file or folder in the archive
84
-	 * @param string $source
85
-	 * @param string $dest
86
-	 * @return boolean|null
87
-	 */
88
-	public function rename($source, $dest) {
89
-		$source = $this->stripPath($source);
90
-		$dest = $this->stripPath($dest);
91
-		$this->zip->renameName($source, $dest);
92
-	}
93
-	/**
94
-	 * get the uncompressed size of a file in the archive
95
-	 * @param string $path
96
-	 * @return int
97
-	 */
98
-	public function filesize($path) {
99
-		$stat = $this->zip->statName($path);
100
-		return $stat['size'];
101
-	}
102
-	/**
103
-	 * get the last modified time of a file in the archive
104
-	 * @param string $path
105
-	 * @return int
106
-	 */
107
-	public function mtime($path) {
108
-		return filemtime($this->path);
109
-	}
110
-	/**
111
-	 * get the files in a folder
112
-	 * @param string $path
113
-	 * @return array
114
-	 */
115
-	public function getFolder($path) {
116
-		$files = $this->getFiles();
117
-		$folderContent = [];
118
-		$pathLength = strlen($path);
119
-		foreach ($files as $file) {
120
-			if (substr($file, 0, $pathLength) == $path and $file != $path) {
121
-				if (strrpos(substr($file, 0, -1), '/') <= $pathLength) {
122
-					$folderContent[] = substr($file, $pathLength);
123
-				}
124
-			}
125
-		}
126
-		return $folderContent;
127
-	}
128
-	/**
129
-	 * get all files in the archive
130
-	 * @return array
131
-	 */
132
-	public function getFiles() {
133
-		$fileCount = $this->zip->numFiles;
134
-		$files = [];
135
-		for ($i = 0;$i < $fileCount;$i++) {
136
-			$files[] = $this->zip->getNameIndex($i);
137
-		}
138
-		return $files;
139
-	}
140
-	/**
141
-	 * get the content of a file
142
-	 * @param string $path
143
-	 * @return string
144
-	 */
145
-	public function getFile($path) {
146
-		return $this->zip->getFromName($path);
147
-	}
148
-	/**
149
-	 * extract a single file from the archive
150
-	 * @param string $path
151
-	 * @param string $dest
152
-	 * @return boolean|null
153
-	 */
154
-	public function extractFile($path, $dest) {
155
-		$fp = $this->zip->getStream($path);
156
-		file_put_contents($dest, $fp);
157
-	}
158
-	/**
159
-	 * extract the archive
160
-	 * @param string $dest
161
-	 * @return bool
162
-	 */
163
-	public function extract($dest) {
164
-		return $this->zip->extractTo($dest);
165
-	}
166
-	/**
167
-	 * check if a file or folder exists in the archive
168
-	 * @param string $path
169
-	 * @return bool
170
-	 */
171
-	public function fileExists($path) {
172
-		return ($this->zip->locateName($path) !== false) or ($this->zip->locateName($path.'/') !== false);
173
-	}
174
-	/**
175
-	 * remove a file or folder from the archive
176
-	 * @param string $path
177
-	 * @return bool
178
-	 */
179
-	public function remove($path) {
180
-		if ($this->fileExists($path.'/')) {
181
-			return $this->zip->deleteName($path.'/');
182
-		} else {
183
-			return $this->zip->deleteName($path);
184
-		}
185
-	}
186
-	/**
187
-	 * get a file handler
188
-	 * @param string $path
189
-	 * @param string $mode
190
-	 * @return bool|resource
191
-	 */
192
-	public function getStream($path, $mode) {
193
-		if ($mode == 'r' or $mode == 'rb') {
194
-			return $this->zip->getStream($path);
195
-		} else {
196
-			//since we can't directly get a writable stream,
197
-			//make a temp copy of the file and put it back
198
-			//in the archive when the stream is closed
199
-			if (strrpos($path, '.') !== false) {
200
-				$ext = substr($path, strrpos($path, '.'));
201
-			} else {
202
-				$ext = '';
203
-			}
204
-			$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
205
-			if ($this->fileExists($path)) {
206
-				$this->extractFile($path, $tmpFile);
207
-			}
208
-			$handle = fopen($tmpFile, $mode);
209
-			return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) {
210
-				$this->writeBack($tmpFile, $path);
211
-			});
212
-		}
213
-	}
45
+    /**
46
+     * @param string $source
47
+     */
48
+    public function __construct($source) {
49
+        $this->path = $source;
50
+        $this->zip = new \ZipArchive();
51
+        if ($this->zip->open($source, \ZipArchive::CREATE)) {
52
+        } else {
53
+            \OCP\Util::writeLog('files_archive', 'Error while opening archive '.$source, ILogger::WARN);
54
+        }
55
+    }
56
+    /**
57
+     * add an empty folder to the archive
58
+     * @param string $path
59
+     * @return bool
60
+     */
61
+    public function addFolder($path) {
62
+        return $this->zip->addEmptyDir($path);
63
+    }
64
+    /**
65
+     * add a file to the archive
66
+     * @param string $path
67
+     * @param string $source either a local file or string data
68
+     * @return bool
69
+     */
70
+    public function addFile($path, $source = '') {
71
+        if ($source and $source[0] == '/' and file_exists($source)) {
72
+            $result = $this->zip->addFile($source, $path);
73
+        } else {
74
+            $result = $this->zip->addFromString($path, $source);
75
+        }
76
+        if ($result) {
77
+            $this->zip->close();//close and reopen to save the zip
78
+            $this->zip->open($this->path);
79
+        }
80
+        return $result;
81
+    }
82
+    /**
83
+     * rename a file or folder in the archive
84
+     * @param string $source
85
+     * @param string $dest
86
+     * @return boolean|null
87
+     */
88
+    public function rename($source, $dest) {
89
+        $source = $this->stripPath($source);
90
+        $dest = $this->stripPath($dest);
91
+        $this->zip->renameName($source, $dest);
92
+    }
93
+    /**
94
+     * get the uncompressed size of a file in the archive
95
+     * @param string $path
96
+     * @return int
97
+     */
98
+    public function filesize($path) {
99
+        $stat = $this->zip->statName($path);
100
+        return $stat['size'];
101
+    }
102
+    /**
103
+     * get the last modified time of a file in the archive
104
+     * @param string $path
105
+     * @return int
106
+     */
107
+    public function mtime($path) {
108
+        return filemtime($this->path);
109
+    }
110
+    /**
111
+     * get the files in a folder
112
+     * @param string $path
113
+     * @return array
114
+     */
115
+    public function getFolder($path) {
116
+        $files = $this->getFiles();
117
+        $folderContent = [];
118
+        $pathLength = strlen($path);
119
+        foreach ($files as $file) {
120
+            if (substr($file, 0, $pathLength) == $path and $file != $path) {
121
+                if (strrpos(substr($file, 0, -1), '/') <= $pathLength) {
122
+                    $folderContent[] = substr($file, $pathLength);
123
+                }
124
+            }
125
+        }
126
+        return $folderContent;
127
+    }
128
+    /**
129
+     * get all files in the archive
130
+     * @return array
131
+     */
132
+    public function getFiles() {
133
+        $fileCount = $this->zip->numFiles;
134
+        $files = [];
135
+        for ($i = 0;$i < $fileCount;$i++) {
136
+            $files[] = $this->zip->getNameIndex($i);
137
+        }
138
+        return $files;
139
+    }
140
+    /**
141
+     * get the content of a file
142
+     * @param string $path
143
+     * @return string
144
+     */
145
+    public function getFile($path) {
146
+        return $this->zip->getFromName($path);
147
+    }
148
+    /**
149
+     * extract a single file from the archive
150
+     * @param string $path
151
+     * @param string $dest
152
+     * @return boolean|null
153
+     */
154
+    public function extractFile($path, $dest) {
155
+        $fp = $this->zip->getStream($path);
156
+        file_put_contents($dest, $fp);
157
+    }
158
+    /**
159
+     * extract the archive
160
+     * @param string $dest
161
+     * @return bool
162
+     */
163
+    public function extract($dest) {
164
+        return $this->zip->extractTo($dest);
165
+    }
166
+    /**
167
+     * check if a file or folder exists in the archive
168
+     * @param string $path
169
+     * @return bool
170
+     */
171
+    public function fileExists($path) {
172
+        return ($this->zip->locateName($path) !== false) or ($this->zip->locateName($path.'/') !== false);
173
+    }
174
+    /**
175
+     * remove a file or folder from the archive
176
+     * @param string $path
177
+     * @return bool
178
+     */
179
+    public function remove($path) {
180
+        if ($this->fileExists($path.'/')) {
181
+            return $this->zip->deleteName($path.'/');
182
+        } else {
183
+            return $this->zip->deleteName($path);
184
+        }
185
+    }
186
+    /**
187
+     * get a file handler
188
+     * @param string $path
189
+     * @param string $mode
190
+     * @return bool|resource
191
+     */
192
+    public function getStream($path, $mode) {
193
+        if ($mode == 'r' or $mode == 'rb') {
194
+            return $this->zip->getStream($path);
195
+        } else {
196
+            //since we can't directly get a writable stream,
197
+            //make a temp copy of the file and put it back
198
+            //in the archive when the stream is closed
199
+            if (strrpos($path, '.') !== false) {
200
+                $ext = substr($path, strrpos($path, '.'));
201
+            } else {
202
+                $ext = '';
203
+            }
204
+            $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
205
+            if ($this->fileExists($path)) {
206
+                $this->extractFile($path, $tmpFile);
207
+            }
208
+            $handle = fopen($tmpFile, $mode);
209
+            return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) {
210
+                $this->writeBack($tmpFile, $path);
211
+            });
212
+        }
213
+    }
214 214
 
215
-	/**
216
-	 * write back temporary files
217
-	 */
218
-	public function writeBack($tmpFile, $path) {
219
-		$this->addFile($path, $tmpFile);
220
-		unlink($tmpFile);
221
-	}
215
+    /**
216
+     * write back temporary files
217
+     */
218
+    public function writeBack($tmpFile, $path) {
219
+        $this->addFile($path, $tmpFile);
220
+        unlink($tmpFile);
221
+    }
222 222
 
223
-	/**
224
-	 * @param string $path
225
-	 * @return string
226
-	 */
227
-	private function stripPath($path) {
228
-		if (!$path || $path[0] == '/') {
229
-			return substr($path, 1);
230
-		} else {
231
-			return $path;
232
-		}
233
-	}
223
+    /**
224
+     * @param string $path
225
+     * @return string
226
+     */
227
+    private function stripPath($path) {
228
+        if (!$path || $path[0] == '/') {
229
+            return substr($path, 1);
230
+        } else {
231
+            return $path;
232
+        }
233
+    }
234 234
 }
Please login to merge, or discard this patch.