Code Duplication    Length = 14-14 lines in 2 locations

lib/Service/MiscService.php 1 location

@@ 383-396 (lines=14) @@
380
	 *
381
	 * @return string
382
	 */
383
	public function token(int $length = 0): string {
384
		$chars = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890';
385
386
		$str = '';
387
		$max = strlen($chars) - 1;
388
		for ($i = 0; $i <= $length; $i++) {
389
			try {
390
				$str .= $chars[random_int(0, $max)];
391
			} catch (Exception $e) {
392
			}
393
		}
394
395
		return $str;
396
	}
397
398
399
	/**

lib/ShareByCircleProviderDeprecated.php 1 location

@@ 1012-1025 (lines=14) @@
1009
	 *
1010
	 * @return string
1011
	 */
1012
	protected function token(int $length = 15): string {
1013
		$chars = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890';
1014
1015
		$str = '';
1016
		$max = strlen($chars);
1017
		for ($i = 0; $i < $length; $i++) {
1018
			try {
1019
				$str .= $chars[random_int(0, $max - 1)];
1020
			} catch (Exception $e) {
1021
			}
1022
		}
1023
1024
		return $str;
1025
	}
1026
1027
1028
}