Updated logic to generate random short codes, increasing entropy

This commit is contained in:
Alejandro Celaya
2019-10-11 09:14:25 +02:00
parent c8d950e04d
commit 2f09ff456c
13 changed files with 91 additions and 149 deletions

View File

@@ -8,26 +8,12 @@ use Zend\Stdlib\AbstractOptions;
class UrlShortenerOptions extends AbstractOptions
{
public const DEFAULT_CHARS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
// phpcs:disable
protected $__strictMode__ = false;
// phpcs:enable
private $shortcodeChars = self::DEFAULT_CHARS;
private $validateUrl = true;
public function getChars(): string
{
return $this->shortcodeChars;
}
protected function setShortcodeChars(string $shortcodeChars): self
{
$this->shortcodeChars = empty($shortcodeChars) ? self::DEFAULT_CHARS : $shortcodeChars;
return $this;
}
public function isUrlValidationEnabled(): bool
{
return $this->validateUrl;