@@ -237,13 +237,13 @@ class Sqids implements SqidsInterface
237
237
238
238
protected MathInterface $ math ;
239
239
240
- protected ?string $ blocklist = null ;
240
+ protected ?string $ blocklistRegex = null ;
241
241
242
- /** @throws \ InvalidArgumentException */
242
+ /** @throws InvalidArgumentException */
243
243
public function __construct (
244
244
protected string $ alphabet = self ::DEFAULT_ALPHABET ,
245
245
protected int $ minLength = self ::DEFAULT_MIN_LENGTH ,
246
- array $ blocklist = self ::DEFAULT_BLOCKLIST ,
246
+ protected array $ blocklist = self ::DEFAULT_BLOCKLIST ,
247
247
) {
248
248
$ this ->math = $ this ->getMathExtension ();
249
249
@@ -270,15 +270,14 @@ public function __construct(
270
270
);
271
271
}
272
272
273
- // Filter out blocklist words that are shorter than 3 characters or contain non-alphabet characters
274
273
$ filteredBlocklist = [];
275
274
foreach ($ blocklist as $ word ) {
276
275
if (strlen ((string ) $ word ) >= 3 ) {
277
276
$ filteredBlocklist [] = strtr (preg_quote ((string ) $ word , '/ ' ), self ::LEET );
278
277
}
279
278
}
280
279
if ($ filteredBlocklist ) {
281
- $ this ->blocklist = '/( ' . implode ('| ' , $ filteredBlocklist ) . ')/i ' ;
280
+ $ this ->blocklistRegex = '/( ' . implode ('| ' , $ filteredBlocklist ) . ')/i ' ;
282
281
}
283
282
284
283
$ this ->alphabet = $ this ->shuffle ($ alphabet );
@@ -448,7 +447,7 @@ protected function toNumber(string $id, string $alphabet): int
448
447
449
448
protected function isBlockedId (string $ id ): bool
450
449
{
451
- return $ this ->blocklist !== null && preg_match ($ this ->blocklist , $ id );
450
+ return $ this ->blocklistRegex !== null && preg_match ($ this ->blocklistRegex , $ id );
452
451
}
453
452
454
453
protected static function maxValue (): int
0 commit comments