Files
SyliusCmsPlugin/tests/Behat/Service/RandomStringGenerator.php
T
2017-11-24 07:40:07 +01:00

31 lines
847 B
PHP
Executable File

<?php
/**
* This file was created by the 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.
*/
namespace Tests\BitBag\SyliusCmsPlugin\Behat\Service;
final class RandomStringGenerator implements RandomStringGeneratorInterface
{
/**
* {@inheritdoc}
*/
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;
}
}