Files
SyliusCmsPlugin/tests/Behat/Service/RandomStringGenerator.php
2018-07-11 20:44:20 +02:00

30 lines
836 B
PHP
Executable File

<?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.shop and write us
* an email on mikolaj.krol@bitbag.pl.
*/
declare(strict_types=1);
namespace Tests\BitBag\SyliusCmsPlugin\Behat\Service;
final class RandomStringGenerator implements RandomStringGeneratorInterface
{
public function generate(int $length = 10): string
{
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; ++$i) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
}