diff --git a/src/Sqids.php b/src/Sqids.php index a6b8e03..8860cdd 100644 --- a/src/Sqids.php +++ b/src/Sqids.php @@ -231,13 +231,13 @@ class Sqids implements SqidsInterface protected MathInterface $math; - protected ?string $blocklist = null; + protected ?string $blocklistRegex = null; - /** @throws \InvalidArgumentException */ + /** @throws InvalidArgumentException */ public function __construct( protected string $alphabet = self::DEFAULT_ALPHABET, protected int $minLength = self::DEFAULT_MIN_LENGTH, - array $blocklist = self::DEFAULT_BLOCKLIST, + protected array $blocklist = self::DEFAULT_BLOCKLIST, ) { $this->math = $this->getMathExtension(); @@ -268,7 +268,6 @@ public function __construct( ); } - // Filter out blocklist words that are shorter than 3 characters or contain non-alphabet characters $filteredBlocklist = []; foreach ($blocklist as $word) { if (strlen((string) $word) >= 3) { @@ -276,7 +275,7 @@ public function __construct( } } if ($filteredBlocklist) { - $this->blocklist = '/(' . implode('|', $filteredBlocklist) . ')/i'; + $this->blocklistRegex = '/(' . implode('|', $filteredBlocklist) . ')/i'; } $this->alphabet = $this->shuffle($alphabet); @@ -454,7 +453,7 @@ protected function toNumber(string $id, string $alphabet): int protected function isBlockedId(string $id): bool { - return $this->blocklist !== null && preg_match($this->blocklist, $id); + return $this->blocklistRegex !== null && preg_match($this->blocklistRegex, $id); } protected static function maxValue(): int