for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace BitBag\SyliusWishlistPlugin\Entity;
class WishlistToken implements WishlistTokenInterface
{
protected $value;
public function __construct(?string $value = null)
if ($value === null) {
$this->value = $this->generate(self::VALUE_LENGTH);
} else {
$this->setValue($value);
}
public function getValue(): string
return $this->value;
public function setValue(string $value): void
$this->value = $value;
public function __toString()
return $this->getValue();
private function generate($length): string
$token = '';
$codeAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$codeAlphabet .= 'abcdefghijklmnopqrstuvwxyz';
$codeAlphabet .= '0123456789';
$max = strlen($codeAlphabet); // edited
for ($i = 0; $i < $length; ++$i) {
$token .= $codeAlphabet[random_int(0, $max - 1)];
return $token;