public static function getRandomString($length = 15, $numeric = true, $lowercase = true, $uppercase = true, $special = true)
{
// init
$characters = '';
$string = '';
$charset = FrontendModel::getContainer()->getParameter('kernel.charset');
// possible characters
if ($numeric) {
$characters .= '1234567890';
}
if ($lowercase) {
$characters .= 'abcdefghijklmnopqrstuvwxyz';
}
if ($uppercase) {
$characters .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
}
if ($special) {
$characters .= '-_.:;,?!@#&=)([]{}*+%$';
}
// get random characters
for ($i = 0; $i < $length; ++$i) {
// random index
$index = mt_rand(0, mb_strlen($characters));
// add character to salt
$string .= mb_substr($characters, $index, 1, $charset);
}
return $string;
}