public static function randomString(int $length = 64, string $characters = self::PRINTABLE_ASCII) : string
{
$str = '';
$l = self::stringLength($characters) - 1;
for ($i = 0; $i < $length; ++$i) {
$r = \random_int(0, $l);
$str .= $characters[$r];
}
return $str;
}
/** * @covers Util::randomString() */ public function testRandomString() { $sample = [Util::randomString(), Util::randomString()]; $this->assertNotSame($sample[0], $sample[1]); }