Skip to content

Commit

Permalink
Moved user search phrase pattern to const
Browse files Browse the repository at this point in the history
  • Loading branch information
ciastektk committed Dec 19, 2024
1 parent bb77f85 commit 6eec554
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib/QueryType/UserQueryType.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

final class UserQueryType extends AbstractQueryType
{
private const USER_SEARCH_PHRASE_PATTERN = '/[^a-zA-Z0-9@._-]/';

protected function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
Expand Down Expand Up @@ -80,7 +82,7 @@ public static function getName(): string

private function cleanSearchPhrase(string $phrase): string
{
$sanitizedPhrase = preg_replace('/[^a-zA-Z0-9@._-]/', '', $phrase);
$sanitizedPhrase = preg_replace(self::USER_SEARCH_PHRASE_PATTERN, '', $phrase);
if (null === $sanitizedPhrase) {
throw new RuntimeException('Could not sanitize search phrase.');
}
Expand Down

0 comments on commit 6eec554

Please sign in to comment.