Skip to content

Commit

Permalink
Make sure pattern is not an empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
christeredvartsen committed Sep 9, 2023
1 parent c2f6f36 commit 2593749
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ArrayContainsComparator/Matcher/RegExp.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public function __invoke(string|int|float $subject, string $pattern): bool
{
$subject = (string) $subject;

if ('' === $pattern) {
throw new InvalidArgumentException('Pattern can not be empty.');
}

if (!preg_match($pattern, $subject)) {
throw new InvalidArgumentException(sprintf(
'Subject "%s" did not match pattern "%s".',
Expand Down

0 comments on commit 2593749

Please sign in to comment.