matching
This commit is contained in:
parent
058e700f49
commit
9777669f84
@ -8,10 +8,15 @@ final class StringMatcher
|
||||
{
|
||||
public static function match(string $input, string $pattern, StringMatchMode $mode): bool
|
||||
{
|
||||
if (empty($input) || empty($pattern)) {
|
||||
if (blank($input) || blank($pattern)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($mode !== StringMatchMode::Regex) {
|
||||
$input = strtolower($input);
|
||||
$pattern = strtolower($pattern);
|
||||
}
|
||||
|
||||
return match ($mode) {
|
||||
StringMatchMode::Exact => strcasecmp($input, $pattern) === 0,
|
||||
StringMatchMode::Contains => str_contains($input, $pattern) ,
|
||||
|
Loading…
Reference in New Issue
Block a user