From e916c3d07ec4d0857fbeb4a452a7a7024c63bb4c Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 21 Feb 2017 09:13:39 +0100 Subject: [PATCH] Move method 'createRandomString' from class 'Auth' to 'UserManager' --- src/Auth.php | 18 ------------------ src/UserManager.php | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Auth.php b/src/Auth.php index 0a7490c..7df90d2 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -1397,24 +1397,6 @@ final class Auth extends UserManager { return $params; } - /** - * Creates a random string with the given maximum length - * - * With the default parameter, the output should contain at least as much randomness as a UUID - * - * @param int $maxLength the maximum length of the output string (integer multiple of 4) - * @return string the new random string - */ - public static function createRandomString($maxLength = 24) { - // calculate how many bytes of randomness we need for the specified string length - $bytes = floor(intval($maxLength) / 4) * 3; - // get random data - $data = openssl_random_pseudo_bytes($bytes); - - // return the Base64-encoded result - return Base64::encode($data, true); - } - /** * Creates a UUID v4 as per RFC 4122 * diff --git a/src/UserManager.php b/src/UserManager.php index 6fb33bf..90021e6 100644 --- a/src/UserManager.php +++ b/src/UserManager.php @@ -27,6 +27,24 @@ abstract class UserManager { /** @var PdoDatabase the database connection to operate on */ protected $db; + /** + * Creates a random string with the given maximum length + * + * With the default parameter, the output should contain at least as much randomness as a UUID + * + * @param int $maxLength the maximum length of the output string (integer multiple of 4) + * @return string the new random string + */ + public static function createRandomString($maxLength = 24) { + // calculate how many bytes of randomness we need for the specified string length + $bytes = floor(intval($maxLength) / 4) * 3; + // get random data + $data = openssl_random_pseudo_bytes($bytes); + + // return the Base64-encoded result + return Base64::encode($data, true); + } + /** * @param PdoDatabase|PdoDsn|\PDO $databaseConnection the database connection to operate on */