<?php namespace App\Helper; /** * Helper to generate strings */ class StringGenerationHelper { /** * Generate an random string * * @param array $base Charset to generate the random string * @param int $length Length of the random string * @return string */ public static function generateString(array $base, int $length): string { $output = ''; for ($index = 0; $index < $length; $index ++) { $output .= $base[rand(0, count($base) - 1)]; } return $output; } }